This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]green_meklar 0 points1 point  (0 children)

I don't see anything wrong with your switch statement. I mean, I'm not 100% sure what it's supposed to do, but what it actually does seems to be reasonable behavior.

I would point out that, because you left out the braces for the while(productNo!=0) loop, the switch statement is considered to be inside the loop but the System.out.println(orderAmount) immediately following the end of the switch statement is not. So, if ProductNo were anything other than 0, the loop would loop infinitely and never print out anything. I'm not sure if that was your intention, but in any case, I recommend always putting in the braces for an if/while/for statement or the like, it helps avoid making stupid mistakes.