System.out.println("Enter the answers pressing enter after every input : ");
for(int x = 0; x < 20; x++) {
do {
studentAnswers[x] = keyboard.next().toUpperCase();
System.out.println(studentAnswers[x]);
if (!"A".equals(studentAnswers[x]) || !"B".equals(studentAnswers[x]) ||
!"C".equals(studentAnswers[x]) || !"D".equals(studentAnswers[x]))
System.out.println("You entered an invalid input.");
} while(!"A".equals(studentAnswers[x]) || !"B".equals(studentAnswers[x]) ||
!"C".equals(studentAnswers[x]) || !"D".equals(studentAnswers[x]));
}
Above is my code. For whatever reason, the condition for both the if statement and do-while loop are not recognizing the correct inputs. For example, if I input a, it will print "You entered an invalid input." I even had my teacher look at this. Unfortunately, he could not find an answer either. The array studentAnswers is a String, and I even have the line below the input to ensure that the input is being stored correctly.
I would appreciate any help in solving this problem. Thanks in advance!