Originally posted by rix
I have this statement
Code:
while ((userInput!='1')&&(userInput!='2')&&(userInput!='3')){
if the user doesnt enter 1,2 or 3 the program will loop til they do. [/B]
the solution is inherent in the statement you just made.. you say "1 or 2 or 3", and then you are using the AND operator in java.. you want an OR 
this code works:
Code:
char userInput = '0';
while ((userInput!='1')||(userInput!='2')||(userInput!='3')){
System.out.print("Please enter 1, 2 or 3:");
userInput=in.readCharacter();
}
Bookmarks