This content has been marked as final. Show 8 replies
Let's simplify that condition in your while loop a bit: suppose the user is
supposed to type 'a' or 'b', anything else is assumed to be wrong. You
Suppose I type 'b', it definitely isn't an 'a' so your condition will be true,
while (input != 'a' || input != 'b') ...
which is not what you want. I normally do it like this:
String responseChars= "..."; while (responseChars.indexOf(input) < 0) ...
I did try using && instead of ||, but that didn'tYes that works, and might be easier to understand. But did you really try this?
However, the other response in this topic does solve
my problem. Thank you :)
while (selection != 'c' && selection != 'C' && selection != 's' && selection != 'S' && selection != 'e' && selection != 'E' )
Well, I thought I did.
I've just tried it using that again, because I can understand why it would work, and so was curious to see if it did or not. It worked using that method too this time lol, so there must have been another fault in my code somewhere last time I tried that which somehow caused it not to.
Thanks again for the help.