Computer Science Canada Looping/Valid/Invalid Input... |
Author: | Hunter007 [ Wed Jan 14, 2004 6:27 pm ] | ||
Post subject: | Looping/Valid/Invalid Input... | ||
I've been working on a lot of different progs at the same time (school) and I seem to have gotten confused. This program here is supposed to calculate any amount of pizzas(any size) with any number of toppings. No tax is needed. I think it calculates one order at a time now. I;m posting my code, hoping someone can help me out.
|
Author: | poly [ Wed Jan 14, 2004 7:47 pm ] | ||
Post subject: | |||
I see what your error is and its a very simple one, just have to move a line up. Here I posted the code below, you can see what I moved to fix this error, I made comment:
the formula " totalcost := totalcost + cost " was after the CLS, so when it was time to tally it all up the CLS would just clear all vars. So I just moved it above the CLS and presto! |
Author: | Thuged_Out_G [ Thu Jan 15, 2004 10:36 am ] |
Post subject: | |
cls only clears the screen, it doesnt clear variables |
Author: | DanShadow [ Thu Jan 15, 2004 1:47 pm ] |
Post subject: | |
No, no, no...poly is right, and he wasnt clearing variables. Hunter007 wrote: cls end loop totalcost := totalcost + cost poly wrote: totalcost := totalcost + cost % I JUST MOVED THIS LINE BEFORE THE CLS cls end loop See, poly moved the totalcost calculator from outside the loop, to inside above the cls...he wasnt try to stop cls from clearing variables or anything. |
Author: | Thuged_Out_G [ Thu Jan 15, 2004 2:52 pm ] |
Post subject: | |
thats just the mesasge i got from poly wrote: CLS would just clear all vars |