Im doing an assignment that requires me to code a vending machine. Im currently stuck in a part where on the second time it loops, it doesnt proceed down to case 1 when input is 1, it just loops forever. Im a beginner, any help will be appreciated.
at this point, 'option' is not initialised, it could be any value, so you need initialise it when you declare it on line 4. (you are initialising the other variables on this line, which is good).
Also, what compiler are you using? Your issue was picked up by my compiler when i tried to build (which is also a good thing):
Error 1 error C4700: uninitialized local variable 'option' used
Error 2 error C4700: uninitialized local variable 'totalN' used
You are also stuck in the wrong loop due to this line: while (totalN<1.20){
if i put in 1RM, it thanks me (even though this isn't enough?). and then loops again as 1 is less that 1.2.
Ohmygod, it was that simple. Hahaha, okay i get it now. I didnt realize that option and totalN have to be declared 0 too. Im using DevC++
it worked with you guys' help. Thanks =D