Beginner to java. Trying to make it so that my code only takes a certain letter grade input or otherwise exits the system. When I put in this code,
System.out.print("What letter grade do you want to achieve for the course? ");
char desiredGrade = keyboard.next().toUpperCase().charAt(0);
if (desiredGrade != 'A') {
System.out.println("Invalid input");
System.exit(0);
}
it works fine and reads that any other input other than 'A' is an invalid input. However, when I add an OR such as
System.out.print("What letter grade do you want to achieve for the course? ");
char desiredGrade = keyboard.next().toUpperCase().charAt(0);
if (desiredGrade != 'A' || desiredGrade != 'B') {
System.out.println("Invalid input");
System.exit(0);
}
it runs through the if statement even though the user inputs A or B. Is this a simple writing error that I am missing? Thanks!