I have a method here that is supposed to check if a user has entered a "y", pertaining to the answer yes; or an "n" pertaining to the answer no. It reads in the letters entered by the user correctly, however it keeps saying that the user has not entered a "y" or an "n". If someone could let me know what I'm doing wrong that would be great. Here is the code I'm using :
String answer = "";
do {
while (answer.equals("")) {
answer = sc.nextLine();
}
if (!answer.equals("y") || !answer.equals("n")) {
System.out.println("Please enter a y, meaning yes; or an n, meaning no.");
answer = "";
}
} while (!answer.equals("y") || !answer.equals("n"));