Here is a class I made that is able to ask a teacher what percentage their student has in a class and gives them back a grade. The code is very repetitive and I am wondering what I can do to simplify the class below before inputting any more grades.
import java.util.Scanner;
public class Grades{
public static void main(String [] args){
Scanner grades = new Scanner(System.in);
int x = 0;
System.out.print("What is the percentage of the student: ");
x = grades.nextInt();
if (x > 100 || x < 0){
System.out.println("Please put in a percent from 0 - 100!\n");
}
while (x > 100 || x < 0 ){
System.out.print("What is the percentage of the student: ");
x = grades.nextInt();
if (x > 100 || x < 0){
System.out.println("Please put in a percent from 0 - 100!\n");
}
}
if (x <= 100 && x >= 96){
System.out.print("A+");
}
if (x <= 95 && x >= 92){
System.out.print("A");
}
if (x <= 91 && x >= 90){
System.out.print("A-");
}
if (x <= 89 && x >= 50){
System.out.print("B+");
}
if (x <= 49 && x >= 0){
System.out.print("B");
}
// so on and so forth down the grading scale
}
}