Just give me your e mail and I can e mail you the first chapter or all of what I have so far, or whatever you want. I'm just feeling bored and random and needing opinons.
STORY A: a teenage girl dies and it's about her experiences in the afterlife. Only a little of teen partying.
STORY B: a historical taking place in Britain in the 1800s. a tough girl battles her past and a friend who wants to be more. Totally clean. Working on chapter three now.
STORY C: a modern story about a 22 year old woman who's life goal is to write a poem about love. So she dates men and when she can't write the poem she dumps them. Until she gets dumped first for the first time in her life. Very funny, mild language. Prologue and Chapter One are finished.
If you don't want to read, which would you most like to read?
Who would like to read the beginnings of one of my novels for random fun?
no
Reply:i would like to read story a and c.
hit me up:mikaa219@ yahoo.com
looking foward to it Report It
Reply:Story A or C.
But I prefer reading stuff about guys being the main character because it's really rare to find that in teen targeted books nowadays.
Reply:Steph, it's too hard to pick! Give me more details in an e-mail plzzzzzzz.
Reply:i would not mind reading on any of them, but shouldn't you get into one book at a time? just a thought. i don't know if that's good advice because j.k. rowling was in the middle of writing harry potter she was in the middle of another book. go figure.
Reply:al1enfreak@yahoo.com
Friday, July 31, 2009
Credit card company wants to estimate the average balance of its customers. A random sample of 20 customers...
A credit card company wants to estimate the average balance of its customers. A random sample of 20 customers shows a sample standard deviation of $43. Construct a 99% confidence interval for the standard deviation of the balance.
a. (6.84398, 38.5822)
b. (910.5494, 5133.1243)
c. (30.1753, 71.6458)
d. (31.1563, 67.8430)
Credit card company wants to estimate the average balance of its customers. A random sample of 20 customers...
Since answers a and b do not bracket the sample SD, they are almost certainly not correct. (However, it turns out they are not just random choices, as you will see.)
Assuming the average balances are normally distributed, then
L1 = (n-1) S^2 / chisq_(1 - a/2) and
L2 = (n-1) S^2 / chisq_(a/2)
form a 100(1-a)% confidence interval for the variance of the balance, where n is the sample size, S^2 is the sample variance, and chisq_(1 - a/2) and chisq(a/2) are, respectively, the 100(1 - a/2) and 100 a/2 chi-square percentiles of the xhi-square distribution with (n-1) degrees of freedom. (This should be in your book or class notes.)
For a=0.01,
chisq(a/2) = chisq(.005) = 6.84398 and
chisq(1 - a/2) = chisq(.995) = 38.5822
(Compare these values with answer a.)
If you use these values to compute L1 and L2, you will get the range given by answer b. But this is the confidence interval for the variance, and you've been asked for a confidence interval for the standard deviation. So if
L1 %26lt; sigma_squared %26lt; L2 is a 99% confidence interval for the variance, then it would seem reasonable to me that
sqrt(L1) %26lt; sigma %26lt; sqrt(L2) would be a 99% confidence interval for the standard deviation. If so, the answer is c.
Reply:lol
Reply:No
a. (6.84398, 38.5822)
b. (910.5494, 5133.1243)
c. (30.1753, 71.6458)
d. (31.1563, 67.8430)
Credit card company wants to estimate the average balance of its customers. A random sample of 20 customers...
Since answers a and b do not bracket the sample SD, they are almost certainly not correct. (However, it turns out they are not just random choices, as you will see.)
Assuming the average balances are normally distributed, then
L1 = (n-1) S^2 / chisq_(1 - a/2) and
L2 = (n-1) S^2 / chisq_(a/2)
form a 100(1-a)% confidence interval for the variance of the balance, where n is the sample size, S^2 is the sample variance, and chisq_(1 - a/2) and chisq(a/2) are, respectively, the 100(1 - a/2) and 100 a/2 chi-square percentiles of the xhi-square distribution with (n-1) degrees of freedom. (This should be in your book or class notes.)
For a=0.01,
chisq(a/2) = chisq(.005) = 6.84398 and
chisq(1 - a/2) = chisq(.995) = 38.5822
(Compare these values with answer a.)
If you use these values to compute L1 and L2, you will get the range given by answer b. But this is the confidence interval for the variance, and you've been asked for a confidence interval for the standard deviation. So if
L1 %26lt; sigma_squared %26lt; L2 is a 99% confidence interval for the variance, then it would seem reasonable to me that
sqrt(L1) %26lt; sigma %26lt; sqrt(L2) would be a 99% confidence interval for the standard deviation. If so, the answer is c.
Reply:lol
Reply:No
In the town of Springdale, 30% of the families p=.30 regularly plant vegetable gardens. A random sample?
In the town of Springdale, 30% of the families p=.30 regularly plant vegetable gardens. A random sample of n=100 families is selected for a particular study. What is the probability that the sample proportion, the proportion of families who plant a vegetable garden, is between .20 and .40
a. .0146
b. .0292
c. .4854
d. .9708
e. None of the above.
The U.S Bureau of the census reported mean hourly earnings in the wholesale trade industry of u=9.70 per hour in 1987. A random sample of n=49 wholesale trade workers in a particular city showed a sample mean hourly wage of x=9.30 per hour with a standard deviation of s=1.05 per hour. Test to see if wage rates in the city differ significantly from the reported 9.70.
In the town of Springdale, 30% of the families p=.30 regularly plant vegetable gardens. A random sample?
Let X be the number of families that plant vegetable gardens. X has the binomial distribution with n = 100 trials and success probability p = 0.30
In general, if X has the binomial distribution with n trials and a success probability of p then
P[X = x] = n!/(x!(n-x)!) * p^x * (1-p)^(n-x)
for values of x = 0, 1, 2, ..., n
P[X = x] = 0 for any other value of x.
this is found by looking at the number of combination of x objects chosen from n objects and then a total of x success and n - x failures.
Or, to be more accurate, the binomial is the sum of n independent and identically distributed Bernoulli trials.
the mean of the binomial distribution is n * p
the variance of the binomial distribution is n * p * (1 - p)
Find P( 20 ≤ X ≤ 40) = 0.9786144
to use the normal approximation to the binomial you need to have at least 10 expected failures and at least 10 expected successes.
expected successes are n * p %26gt; 10
expected failures are n * (1 - p) %26gt; 10
don't forget to use the continuity correction. Draw the histogram of the binomial and shade in the boxes you need to help make sure you do this correctly.
Xn is the normal approximation
Xn ~ Normal(μ = n * p, σ = sqrt(n * p * (1-p)))
Xn ~ Normal(μ = 30, σ = sqrt(21))
Find P( 20 ≤ X ≤ 40)
≈ P(19.5 %26lt; Xn %26lt; 40.5)
= P( (19.5 - 30) / sqrt(21) %26lt; Z %26lt; (40.5 - 30) / sqrt(21))
= P(-2.291288 %26lt; Z %26lt; 2.291288)
= P( Z %26lt; 2.291288) - P( Z %26lt; -2.291288)
= 0.98902662 - 0.01097338
= 0.9780532
----------------------------
Hypothesis Test for mean:
assuming you have a large enough sample such that the central limit theorem holds and the mean is normally distributed then to test the null hypothesis H0: μ = Δ
find the test statistic z = (xBar - Δ) / (sx / sqrt(n))
where xbar is the sample average
sx is the sample standard deviation
n is the sample size
The p-value of the test is the area under the normal curve that is in agreement with the alternate hypothesis.
H1: p %26gt; p0; p-value is the area to the right of z
H1: p %26lt; p0; p-value is the area to the left of z
H1: p ≠ p0; p-value is the area in the tails greater than |z|
the test statistic for the US Bureau question is:
z = (9.30 - 9.70) / (1.05 / sqrt(49))
z = -2.666667
p-value = P( |Z| %26gt; 2.666667) = 0.007660754
with a low p-value we can reject the null hypothesis and conclude the alternate is true that wage is different.
survey for cash
a. .0146
b. .0292
c. .4854
d. .9708
e. None of the above.
The U.S Bureau of the census reported mean hourly earnings in the wholesale trade industry of u=9.70 per hour in 1987. A random sample of n=49 wholesale trade workers in a particular city showed a sample mean hourly wage of x=9.30 per hour with a standard deviation of s=1.05 per hour. Test to see if wage rates in the city differ significantly from the reported 9.70.
In the town of Springdale, 30% of the families p=.30 regularly plant vegetable gardens. A random sample?
Let X be the number of families that plant vegetable gardens. X has the binomial distribution with n = 100 trials and success probability p = 0.30
In general, if X has the binomial distribution with n trials and a success probability of p then
P[X = x] = n!/(x!(n-x)!) * p^x * (1-p)^(n-x)
for values of x = 0, 1, 2, ..., n
P[X = x] = 0 for any other value of x.
this is found by looking at the number of combination of x objects chosen from n objects and then a total of x success and n - x failures.
Or, to be more accurate, the binomial is the sum of n independent and identically distributed Bernoulli trials.
the mean of the binomial distribution is n * p
the variance of the binomial distribution is n * p * (1 - p)
Find P( 20 ≤ X ≤ 40) = 0.9786144
to use the normal approximation to the binomial you need to have at least 10 expected failures and at least 10 expected successes.
expected successes are n * p %26gt; 10
expected failures are n * (1 - p) %26gt; 10
don't forget to use the continuity correction. Draw the histogram of the binomial and shade in the boxes you need to help make sure you do this correctly.
Xn is the normal approximation
Xn ~ Normal(μ = n * p, σ = sqrt(n * p * (1-p)))
Xn ~ Normal(μ = 30, σ = sqrt(21))
Find P( 20 ≤ X ≤ 40)
≈ P(19.5 %26lt; Xn %26lt; 40.5)
= P( (19.5 - 30) / sqrt(21) %26lt; Z %26lt; (40.5 - 30) / sqrt(21))
= P(-2.291288 %26lt; Z %26lt; 2.291288)
= P( Z %26lt; 2.291288) - P( Z %26lt; -2.291288)
= 0.98902662 - 0.01097338
= 0.9780532
----------------------------
Hypothesis Test for mean:
assuming you have a large enough sample such that the central limit theorem holds and the mean is normally distributed then to test the null hypothesis H0: μ = Δ
find the test statistic z = (xBar - Δ) / (sx / sqrt(n))
where xbar is the sample average
sx is the sample standard deviation
n is the sample size
The p-value of the test is the area under the normal curve that is in agreement with the alternate hypothesis.
H1: p %26gt; p0; p-value is the area to the right of z
H1: p %26lt; p0; p-value is the area to the left of z
H1: p ≠ p0; p-value is the area in the tails greater than |z|
the test statistic for the US Bureau question is:
z = (9.30 - 9.70) / (1.05 / sqrt(49))
z = -2.666667
p-value = P( |Z| %26gt; 2.666667) = 0.007660754
with a low p-value we can reject the null hypothesis and conclude the alternate is true that wage is different.
survey for cash
A few C++ questions?
Hey guys, just got a few c++ questions
1. What is an unsigned int?
2. When writing a boolean expression are numbers (other than 0) and "true" interchangable? (ie. bool a = true; is the same as bool a = 23;)
3. Can a float be an integer? (ie. float a = 6;)
4. What are substrings and how do you use them?
5. What order do you do commands like %26amp;%26amp;, || and ! in?
6. In relation to the commands above, what combos produce what? (f || t %26amp;%26amp; t || t yield what?)
7. How do you create random numbers (I remember my GSI telling us about special libraries that have to be called, what are they?)
Thanks
A few C++ questions?
1) The difference between signed and unsigned is how the computer interprets a particular bit pattern. For example, take an 8 bit byte.
If you tell the compiler this is an unsigned byte, the values range from 0 to 255. A signed 8 bit integer ranges from -128 to +127. unsigned integers are %26gt;= 0, ranging from 0 to (2^n) - 1.
2) yes. In any statement that takes a boolean expression (if, while, for. ?, until) any non-zero numeric value is treated as true and 0 is treated as false.
3) Yes, floats can represent some integers. Because of the float representation, there are some integers float cannot directly represent (though small integers are fine).
4) This is a very open question. Technically a substring is any inner portion of a source string. If you have a char pointer that points to a source string, you can make another pointer that points to somewhere inside the source string. What you do with it is up to you. You can parse for words, search for a token. Who knows what?
5) || has the lowest precedence, then %26amp;%26amp;, and ! is the highest of the 3
6) You didn't list any commands, so your example:
f || t %26amp;%26amp; t || t
%26amp;%26amp; is highest. t %26amp;%26amp; t -%26gt; t
f || t || t -%26gt; f || t
7) You call the standard library function rand(). Writing a good pseudorandom function is very difficult. Since computers are deterministic, the functions are not truly random, that's why they are called pseudorandom.
Reply:1. What is an unsigned int?
This is an integer value that is 0 or greater (ie: it does not include negative numbers).
2. When writing a boolean expression are numbers (other than 0) and "true" interchangable? (ie. bool a = true; is the same as bool a = 23;)
I think so. Its not 100% intuitive, but I can remember writing code like 'if (count) { //do something }', but its been a while.
3. Can a float be an integer? (ie. float a = 6;)
I think it has to be 6.0 (although assigning it to 6 might be okay, although it may be stored as 6.0). I am not 100% sure on that one.
4. What are substrings and how do you use them?
Substrings I think are just parts of a string. You can pull out parts and do what you want with them.
5. What order do you do commands like %26amp;%26amp;, || and ! in?
%26amp;%26amp; (and) and || (or) come in between logical arguments eg: (a %26amp;%26amp; B). ! (not) comes before !a
6. In relation to the commands above, what combos produce what? (f || t %26amp;%26amp; t || t yield what?)
f || t -%26gt; False or True = True
t || t -%26gt; True or True = True
(So I believe the entire statement is True)
7. How do you create random numbers (I remember my GSI telling us about special libraries that have to be called, what are they?)
I believe this is rand() or srand(int). The only difference is that srand takes a seed number that is used for calculating the random number. This is useful if you want to create a repeatable randomization. rand() always returns a different number. srand(100) always returns the same random number sequence.
Reply:1-
true = 1 false = 0
however something like this if (23){} a non-zero will be interpreted as true (non-NULL where NULL=0).
2-
unsigned int
The unsigned int type represents an unsigned integer comprised of 2 bytes. It has a range of 0 to 65535.
3- float a =6 is correct
4- a substring is a part of a bigger string. You can take a look at the String class to see how to manipulate strings.
http://www.cppreference.com/cppstring/in...
5- !(not) is always in front of a variable
when using a complicated expression its allways good to use brackets. If you don't use brackets the order is from left to right.
6- f || t %26amp;%26amp; t || l yield should never be used like this.
it should be something like this:
( (f || t) %26amp;%26amp; (t || l ))
7- the answer is described in detail and all different forms are also mentioned.
http://www.daniweb.com/forums/thread1769...
Reply:Hey, I am not sure about all of your questions, but I will try to answer them as best I can:
1. An int that does not have a sign, like 99, 53, 24. -5, -34, -67 all have signs, the '-'. Basically, just any non-negative number.
2. Not really sure, why not try it?
3. I am pretty sure it can, but would be a slight waste of memory to declare it as one, but not use it as one, plus the range of numbers floats can handle is smaller than ints im pretty sure.
4. Substrings are parts of other strings. So, if you have the string "Hello World", you could say that "Hello", "World", " ", "ello worl", "lo wo", or any other part of that string.
5 %26amp; 6. I am not really sure I understand you... first of all, %26amp;%26amp; and || are in a separate category of operators from !. Also, you can use parentheses to group logical statements. So, (f || t) %26amp;%26amp; (t || t) would return true, but I am not sure how it would go without the parentheses. Yet again, just try it!
7. I think you need stdlib.h, and you can use srand(int) to seed the generator, and then when ever you call rand(), a random number will be generated. Remember! Computers can not create random numbers! Thus, in order to create more true random numbers, always seed the generator with something that will be unique each time the program is run, like the current time/date in milliseconds. Try it! do:
cout %26lt;%26lt; rand();
three times inside of a normal program with iostream and stdlib included. You will get the same numbers each time!
Now, add srand(someInt); near the top, and be amazed!
1. What is an unsigned int?
2. When writing a boolean expression are numbers (other than 0) and "true" interchangable? (ie. bool a = true; is the same as bool a = 23;)
3. Can a float be an integer? (ie. float a = 6;)
4. What are substrings and how do you use them?
5. What order do you do commands like %26amp;%26amp;, || and ! in?
6. In relation to the commands above, what combos produce what? (f || t %26amp;%26amp; t || t yield what?)
7. How do you create random numbers (I remember my GSI telling us about special libraries that have to be called, what are they?)
Thanks
A few C++ questions?
1) The difference between signed and unsigned is how the computer interprets a particular bit pattern. For example, take an 8 bit byte.
If you tell the compiler this is an unsigned byte, the values range from 0 to 255. A signed 8 bit integer ranges from -128 to +127. unsigned integers are %26gt;= 0, ranging from 0 to (2^n) - 1.
2) yes. In any statement that takes a boolean expression (if, while, for. ?, until) any non-zero numeric value is treated as true and 0 is treated as false.
3) Yes, floats can represent some integers. Because of the float representation, there are some integers float cannot directly represent (though small integers are fine).
4) This is a very open question. Technically a substring is any inner portion of a source string. If you have a char pointer that points to a source string, you can make another pointer that points to somewhere inside the source string. What you do with it is up to you. You can parse for words, search for a token. Who knows what?
5) || has the lowest precedence, then %26amp;%26amp;, and ! is the highest of the 3
6) You didn't list any commands, so your example:
f || t %26amp;%26amp; t || t
%26amp;%26amp; is highest. t %26amp;%26amp; t -%26gt; t
f || t || t -%26gt; f || t
7) You call the standard library function rand(). Writing a good pseudorandom function is very difficult. Since computers are deterministic, the functions are not truly random, that's why they are called pseudorandom.
Reply:1. What is an unsigned int?
This is an integer value that is 0 or greater (ie: it does not include negative numbers).
2. When writing a boolean expression are numbers (other than 0) and "true" interchangable? (ie. bool a = true; is the same as bool a = 23;)
I think so. Its not 100% intuitive, but I can remember writing code like 'if (count) { //do something }', but its been a while.
3. Can a float be an integer? (ie. float a = 6;)
I think it has to be 6.0 (although assigning it to 6 might be okay, although it may be stored as 6.0). I am not 100% sure on that one.
4. What are substrings and how do you use them?
Substrings I think are just parts of a string. You can pull out parts and do what you want with them.
5. What order do you do commands like %26amp;%26amp;, || and ! in?
%26amp;%26amp; (and) and || (or) come in between logical arguments eg: (a %26amp;%26amp; B). ! (not) comes before !a
6. In relation to the commands above, what combos produce what? (f || t %26amp;%26amp; t || t yield what?)
f || t -%26gt; False or True = True
t || t -%26gt; True or True = True
(So I believe the entire statement is True)
7. How do you create random numbers (I remember my GSI telling us about special libraries that have to be called, what are they?)
I believe this is rand() or srand(int). The only difference is that srand takes a seed number that is used for calculating the random number. This is useful if you want to create a repeatable randomization. rand() always returns a different number. srand(100) always returns the same random number sequence.
Reply:1-
true = 1 false = 0
however something like this if (23){} a non-zero will be interpreted as true (non-NULL where NULL=0).
2-
unsigned int
The unsigned int type represents an unsigned integer comprised of 2 bytes. It has a range of 0 to 65535.
3- float a =6 is correct
4- a substring is a part of a bigger string. You can take a look at the String class to see how to manipulate strings.
http://www.cppreference.com/cppstring/in...
5- !(not) is always in front of a variable
when using a complicated expression its allways good to use brackets. If you don't use brackets the order is from left to right.
6- f || t %26amp;%26amp; t || l yield should never be used like this.
it should be something like this:
( (f || t) %26amp;%26amp; (t || l ))
7- the answer is described in detail and all different forms are also mentioned.
http://www.daniweb.com/forums/thread1769...
Reply:Hey, I am not sure about all of your questions, but I will try to answer them as best I can:
1. An int that does not have a sign, like 99, 53, 24. -5, -34, -67 all have signs, the '-'. Basically, just any non-negative number.
2. Not really sure, why not try it?
3. I am pretty sure it can, but would be a slight waste of memory to declare it as one, but not use it as one, plus the range of numbers floats can handle is smaller than ints im pretty sure.
4. Substrings are parts of other strings. So, if you have the string "Hello World", you could say that "Hello", "World", " ", "ello worl", "lo wo", or any other part of that string.
5 %26amp; 6. I am not really sure I understand you... first of all, %26amp;%26amp; and || are in a separate category of operators from !. Also, you can use parentheses to group logical statements. So, (f || t) %26amp;%26amp; (t || t) would return true, but I am not sure how it would go without the parentheses. Yet again, just try it!
7. I think you need stdlib.h, and you can use srand(int) to seed the generator, and then when ever you call rand(), a random number will be generated. Remember! Computers can not create random numbers! Thus, in order to create more true random numbers, always seed the generator with something that will be unique each time the program is run, like the current time/date in milliseconds. Try it! do:
cout %26lt;%26lt; rand();
three times inside of a normal program with iostream and stdlib included. You will get the same numbers each time!
Now, add srand(someInt); near the top, and be amazed!
2001 BMW 330i A/C problem...need help?
ok well i have a 01 bmw 330i and my a/c was working just fine until last week when it startd to turn off and on at random....anyone know what can be the problem and how much it would cost to get it fixed....
2001 BMW 330i A/C problem...need help?
Common problem with the e46's. You have a bad final stage resistor and needs to be replaced.
http://forum.e46fanatics.com/showthread....
Reply:I believe the auto temp sensor is going wrong.I would consult a BMW approved garage for a diagnostic and quote.
2001 BMW 330i A/C problem...need help?
Common problem with the e46's. You have a bad final stage resistor and needs to be replaced.
http://forum.e46fanatics.com/showthread....
Reply:I believe the auto temp sensor is going wrong.I would consult a BMW approved garage for a diagnostic and quote.
Help on c++ code?
basically asked to create a random character (a-z). user input. and check answer. this is my 1st semester of c++. thank you
char letter ();
char* QUESTION(int);
char* answer(int);
void checkanswer(char, char, int);
int main()
{
srand((unsigned) time(NULL));
int level = 10;
char *output = QUESTION (level);
for (int j=0;j%26lt;level;j++)
{
cout %26lt;%26lt; output[j];
}
char *input = answer(level);
for (int l=0;l%26lt;level;l++)
cout %26lt;%26lt; input[l];
checkanswer(*output, *input, level);
int z;
cin %26gt;%26gt; z;
return 0;
}
char* QUESTION(int level)
{
int initial=122, final=97;
char *questions;
questions= new char[level];
for (int i=0;i%26lt;level;i++)
{
questions[i]= rand() % (122 - 97 + 1) + 97;
}
return questions;
}
char* answer(int level)
{
char *input;
input=new char[level];
cout %26lt;%26lt; "\ntype in your answer now: ";
cin %26gt;%26gt; input;
return input;
}
void checkanswer(char *output, char *input, int level)
{
if (output==input)
cout %26lt;%26lt; "\nTRUE";
else
cout %26lt;%26lt; "\nFALSE";
}
Help on c++ code?
It's a pretty good effort but you have a couple of problems and some style issues.
(1) Your prototype and definition don't match so it wouldn't compile.
void checkanswer(char, char, int);
void checkanswer(char *output, char *input, int level)
(2) You always have to be aware in C++ of who/what/where is responsible for allocating and deleting memory. You allocate your char array in ANSWERS() and pass back the pointer to main(). That's ok (not great) but you never delete[] it anywhere. In this size program it is a meaningless oversight. In the real world it is a potentially deadly memory leak.
Start to think in terms of contracts - who is responsible for what - and stick to it. As a general rule for what you are trying to do - initialize and array - it is better to allocate and delete the array in the calling function and just pass the array to the function that operates on it.
(3) style - never capitalize your function names like QUESTIONS(). Caps are for constants and preprocessor macros. It's a convention, not a language rule, but you will only confuse and annoy other developers by doing it.
(4) Learn to use const. In main(), for instance, "int level = 10;" should be "const int level 10;" and
char* QUESTION(int level) should be
char* QUESTION(const int level)
(5) In answer() you do "input=new char[level];" but I think you only want a single char. You also don't delete it anywhere. You should rethink this whole function.
There were some other minor things but you'll get the hang of it. Good work.
char letter ();
char* QUESTION(int);
char* answer(int);
void checkanswer(char, char, int);
int main()
{
srand((unsigned) time(NULL));
int level = 10;
char *output = QUESTION (level);
for (int j=0;j%26lt;level;j++)
{
cout %26lt;%26lt; output[j];
}
char *input = answer(level);
for (int l=0;l%26lt;level;l++)
cout %26lt;%26lt; input[l];
checkanswer(*output, *input, level);
int z;
cin %26gt;%26gt; z;
return 0;
}
char* QUESTION(int level)
{
int initial=122, final=97;
char *questions;
questions= new char[level];
for (int i=0;i%26lt;level;i++)
{
questions[i]= rand() % (122 - 97 + 1) + 97;
}
return questions;
}
char* answer(int level)
{
char *input;
input=new char[level];
cout %26lt;%26lt; "\ntype in your answer now: ";
cin %26gt;%26gt; input;
return input;
}
void checkanswer(char *output, char *input, int level)
{
if (output==input)
cout %26lt;%26lt; "\nTRUE";
else
cout %26lt;%26lt; "\nFALSE";
}
Help on c++ code?
It's a pretty good effort but you have a couple of problems and some style issues.
(1) Your prototype and definition don't match so it wouldn't compile.
void checkanswer(char, char, int);
void checkanswer(char *output, char *input, int level)
(2) You always have to be aware in C++ of who/what/where is responsible for allocating and deleting memory. You allocate your char array in ANSWERS() and pass back the pointer to main(). That's ok (not great) but you never delete[] it anywhere. In this size program it is a meaningless oversight. In the real world it is a potentially deadly memory leak.
Start to think in terms of contracts - who is responsible for what - and stick to it. As a general rule for what you are trying to do - initialize and array - it is better to allocate and delete the array in the calling function and just pass the array to the function that operates on it.
(3) style - never capitalize your function names like QUESTIONS(). Caps are for constants and preprocessor macros. It's a convention, not a language rule, but you will only confuse and annoy other developers by doing it.
(4) Learn to use const. In main(), for instance, "int level = 10;" should be "const int level 10;" and
char* QUESTION(int level) should be
char* QUESTION(const int level)
(5) In answer() you do "input=new char[level];" but I think you only want a single char. You also don't delete it anywhere. You should rethink this whole function.
There were some other minor things but you'll get the hang of it. Good work.
I met awonderful girl online, but lied to her bout me b/c all we wanted was cyber.How do I tell her the truth?
At 1st, we met in an AIM chatroom and were both looking for the same thing: an easy way to get off. I sent her a random picture of a goodlooking guy I found on the internet b/c I didn’t think she’d be attracted to me then.I never thought I’d talk to her again. We continued talking. We have developed a good friendship and more but basically I know she truly likes “me,” and I truly like her. These past few weeks it's been eating at me. It’s all I can think about, and it’s truly one of the things I regret the most in my life. I never wanted to hurt her, all I want is for our relationship to be honest. I have known her for long, there is no “trust” issue on my behalf of who she is, but she thinks I am someone I am not. She is truly one of the most wonderful people I have ever known, and I cannot bear the idea that I kept myself from her. I can’t keep this up.I want to know her in real life, we might be able to have something between us. How best do I tell her the truth? I can't lie anymore
I met awonderful girl online, but lied to her bout me b/c all we wanted was cyber.How do I tell her the truth?
You said it already in your question. You thought it was a one night cyber thing. It was an impulsive act. She obviously likes the guy she has been talking to. She likes your words and your thoughts. You should tell her right away, but with an explanation that you never meant to mislead her, that you thought she was a transient gift brought to you for the night. Tell her that when you realized she wasn't transient and that your relationship would be long and lasting, you wanted to clear this picture thing up. Then, send her a real picture or three of you. Tell her you understand if she is upset about this, but you beg her forgiveness and understanding. If she has the character that you think she has, she will forgive. If she does not forgive, maybe she wasn't as wonderful as you thought she was.
Give her the gift of the real you and she may reveal to you the gift of the real her. Good luck.
Reply:just come clean about everything , tell her how you fell ...
I met awonderful girl online, but lied to her bout me b/c all we wanted was cyber.How do I tell her the truth?
You said it already in your question. You thought it was a one night cyber thing. It was an impulsive act. She obviously likes the guy she has been talking to. She likes your words and your thoughts. You should tell her right away, but with an explanation that you never meant to mislead her, that you thought she was a transient gift brought to you for the night. Tell her that when you realized she wasn't transient and that your relationship would be long and lasting, you wanted to clear this picture thing up. Then, send her a real picture or three of you. Tell her you understand if she is upset about this, but you beg her forgiveness and understanding. If she has the character that you think she has, she will forgive. If she does not forgive, maybe she wasn't as wonderful as you thought she was.
Give her the gift of the real you and she may reveal to you the gift of the real her. Good luck.
Reply:just come clean about everything , tell her how you fell ...
Subscribe to:
Posts (Atom)