I was completing a high school java project, but I stumbled across this issue that I can't seem to fix no matter what I do.
do //runs until user enters a valid option
{
understood = input.next(); //collects user input
if (!understood.equalsIgnoreCase("yes") || !understood.equalsIgnoreCase("y") || !understood.equalsIgnoreCase("no") || !understood.equalsIgnoreCase("n"))
{
System.out.print("\nHey, man. Answer the question. Yes or no? ");
}
}
while (!understood.equalsIgnoreCase("yes") || !understood.equalsIgnoreCase("y") || !understood.equalsIgnoreCase("no") || !understood.equalsIgnoreCase("n"));
What I'm trying to do is check for invalid input for a string in a yes or no question, but when I run it, no matter what I enter, it is treated as invalid input. I'd really appreciate any help on this, thank you so much! :)