View Single Post
Old 03-22-2004, 08:13 PM   #5 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Not sure Joe, "while(Ans1 == 'Y')" -besides that he needs to initialize "Ans1" first with 'Y' - if he does make these changes, "cout<<"Cost: $"<<Cost<<" "<<"Peak: "<<Peak<<" "<<"Off: "<<Off<<endl;" would never be visible. The whole setup is wrong, but he needs to figure out what will do. I can't since I don't know what exactly is to be achieved.

Also...
Code:
printf("\n\nCost: $%d  Peak: %d   Off: %d", Cost, Peak, Off);
... the first %d should be a %f since Cost is a float, not an int.
So Isioviel, replace it with this code:
Code:
printf("\n\nCost: $%f  Peak: %d   Off: %d", Cost, Peak, Off);
Then another thing left: to make the asci drawing: store the drawing in a 2-dimensional array. Makes the code look neat. or else your code looks like this (yes, start copy and pasting again):
Code:
printf(" FFFFF  A     U   U X   X"
			"\n F     A A    U   U  X X"
			"\n FFFF A   A   U   U   X"
			"\n F   A A A A  U   U  X X"
			"\n F  A       A UUUUU X   X"
			"\n\n FFFF OOO  NN   N EEEE"
			"\n F   O   O N N  N E"
			"\n FFF O   O N  N N EEEE"
			"\n F   O   O N   NN E"
			"\n F    OOO  N    N EEEE" );
Wich is very ugly. Also look at \n. Not \r. Also observe \n\n for the double newline.

Then, did you notice that I can make free calls in Peak and Off? Perhaps this is correct, I can't know.

Also, did you notice I added a "return 0;"? Your main() is an int, so return an int. Most compilers won't give you an error but a warning instead. Some compilers don't even give a warning and convert your int main() to a void main(). Surely we don't want that.

Second last point. Replace your while by:
Code:
while(true)
Because it is exactly the same as your
Code:
while(Ans1='Y')
Just a loop that never finishes. you gotta be more clear about your intentions or try to solve it yourself (it is about the last "challenge" left).

Last point:
A bill like $0.3875964 is not realistic for normal usage (in macro econimics it can be). Better is $0.39 or something. So observe the final code and spot all the changes.
__________________
Valmont is offline   Reply With Quote