Hi people I just need a quick fix on how to do the validation for this question. Unfortunately the book I am using doesnt seem to provide a solution after attempting the program. Here is the the question.
"Write an input validation program that asks the user to enter 'Y', 'y' 'N' or 'n' "
keep in mind it must be done only using a while loop any help would be appreciated.
while(answer != "y" || answer!= "n" )
{
System.out.println("Please use a Y or N");
answer = keyboard.nextLine();
}
that is my current loop but it doesnt seem to work even if i enter y or n in it.
The current output i keep getting is "Please use a Y or N" regardless if I enter the correct letter