I'm very new to this forum and I'm taking an online java class which is slaying me. I am having an issue with this program. It is a program that I had previously written but this time we are to use "if else" statements to do error checking. That idea behind the program is that you are buying an item from a vending machine (25<=cost<=100) in cents and that the items cost must be in 5 cent incriments or multiples of 5 cents. i'm not sure why but at like 40 I'm getting an error saying that the variable "amount" has not been initialized. I can't see any problems with the code but I'm new. Any help would be much appreciated. here's the code:
Simulates a vending machine operation through the use of the remainder operator and keyboard input.
Uses error checking to make sure that the input is greater than or equal to 25 cents or less than or
equal to 100 cents. The input must also be in incriments of 5.
posted 7 years ago
Thanks Bear Bibeault. That is much easier to read now. I might have gotten a reply if I had posted it like this originally.
Got it! I just found out that when you have more than a single line within an else if statement you need to include the multiline body into braces! Thanks for the hint!!! Did you learn on a forum like this? I can normally pick things up like math and physics by just reading the book and doing problems but this is a different story. I spent a hours looking at that exact code and couldn't figure out my mistake.