I have another questoin about a piece of code...I need to make this program loop to read integer values until the user enters 999 and NOT blow-up if they enter something dumb like "abc", "$1,000", or "13.25". Examples would help
I am just starting in Java, and I have a similar problem. Mine reads a string which I convert into a double. But, if a non-numeric character is entered instead, I get an error when parsing into a double. Any help? Thanks!
Well, sounds like you're both doing about the same thing. I would recommend you try to catch the exception. Have you seen examples of a try/catch block? That's what you would use here. Jeffry needs to loop until a valid number is entered, so there will be a loop of some sort too. (I can't tell for M Newhouse - what do you want to do instead of an error?) The loop must be positioned so that you stay inside the loop when an exception is thrown. Unfortunately you're also inside the loop when an exception isn't thrown, so the challenge may be to figure out how to get out of the loop when the number is valid. Let's see what you can come up with.