I need to make a program that calculates the GPA of students. It needs to use multiple methods and I am getting snagged.
public static char grade(Scanner in, String name) {
char grade;
System.out.println("Please enter the grade received in " + name + ": ");
grade = in.next().toUpperCase().charAt(0);
while ((grade != 'A' )|| (grade != 'B') || (grade != 'C') || (grade != 'D') || (grade != 'F') || (grade != 'X')) {
System.out.println("Please re-enter a valid letter grade: ");
grade = in.next().toUpperCase().charAt(0);
}
return grade;
At the point of the while statement, it keeps asking me to re-enter a grade, even when I use A, B , C and so on. Any suggestions?
Edit: Never mind, I think I found my error was using or instead of and.