Randomize

Started by
29 comments, last by jbadams 18 years, 3 months ago
thanks for the advice. hey maybe my teacher would of gave me extra points for doing it ur way but yeah thanks for taking time out of ur life to help me. Like i said before merry christams to everyone and wish u all a safe christmas also
Advertisement
Quote:Original post by Death2You
oh yeah the test was about the randomize and a temperature program that i did:

nsj7myx4

/*Enter Temperature*/
#include <iostream.h>

int main()
{

int Count=0;
double Temperature=0.0;
double Average=0.0;

cout<<endl;
do

{
cout<<"Enter A Temperature (999 to quit)"<<endl;
cin>>Temperature;
Average+=Temperature;
Count++;
}while (Temperature!=999);

Average/=Count;
cout<<"Average Temperature is"<<Average<<endl;

return(0);
}
thats it


Looks like you are adding the 999 to your average temperature, and I would suspect that you don't want to do that.
Don't be afraid to be yourself. Nobody else ever will be.
Can you please explain why im adding 999 to my temprature.
Because "Average += Temperature;" is evaluated in the loop before Temperature gets tested against 999 to escape the loop - when the 999 is input, that's the last time the loop runs, but it still runs - so that value is treated as one of the inputs.
Quote:Original post by Death2You
Q: what is the output produced by the following segment of code?
int x=12
do{
cout<<"*";
x-=3;
}while (x!=1);
cout<<"!";

i know its a simple question! i know the answer now so dont get mad that i dont know cause i do.


Was this code segment what was given on the test? If so, it won't compile and after the semicolon is added it will run for a very long time (1,431,655,769 iterations). The reason being that 12 -3 = 9 - 3 = 6 - 3 = 3 -3 = 0 (not 1), so it will go negative and run until it is positive and then finally end up at 1 after over 1 billion iterations.
Didnt you say in your VB thread that you wouldnt post and ask us to create a program for you again? ;)

Just cause I'm grumpy this morning I'll dig out the quote :P

From the VB Thread earlier this week:
Quote:Original post by Death2You
everyone, if u ever see me ask for help again, i WILL show u my OWN problem so u can guide me and help me instead of making ur own program. i was being an asshole asking for a program to be made. EVERYONE reply to me so i know that u guys are not mad at me


Now this:
Quote:Original post by Death2You
im begging someone to make a simple program for me, or atleast tell me how to output 2 numbers in randomize instead of just one. THANKS GUYS!!!



That said glad you got help ;)

However, I find it a bit anoying that you use these boards to get solutions to your classes, because:

a) it's more or less cheating
b) if you gonna use the internet, just google for the keywords in your class task...and you'll find your finished programs :P
// Jens
Quote:Original post by JensB
Didnt you say in your VB thread that you wouldnt post and ask us to create a program for you again? ;)

Just cause I'm grumpy this morning I'll dig out the quote :P

This thread is a week older than the VB thread, so he didn't ask again.

I agree with your position on asking for solutions to class work.
Point c) You don't really learn how to solve problems, so you don't gain anything for the next time a problem is given. You only learn how to cheat, which isn't good.
Oops! /blush

To much Christmas drink, thanks for pointing it out - my appologiez to you Death, I forgot to check the dates.

Conclusion still holds though.
// Jens
The randomize forum i put up was before the VB forum, so when i said in the VB one that i am not asking for any more programs, i meant from then on. Do you not understand?
So are you guys trying to tell me i shouldn't ask for help anymore and I should fail? I said i'll do my programs first for now on, then you guys can guide me, but on both forums i created, everybody is complaining to me that im not learning. Do you guys think im stupid? Am I useless? I was planning to have a career in programming, but now i have many doubts.

This topic is closed to new replies.

Advertisement