When you have more than possible outcomes, chain conditions with else if. Java checks each condition top to bottom and runs the first block that matches.
int score = 75;
if (score >= 90) {
System.out.println("A");
} else if (score >= 80) {
System.out.println("B");
} else if (score >= 70) {
System.out.println("C");
} else {
System.out.println("F");
}
Only one block runs. Once Java finds a true condition, it skips every remaining else if and the final else. Order matters. If you checked score >= 70 first, a score of would print "C" instead of "A".
The trailing else is optional but recommended. It acts as a catch-all for any value that didn't match earlier conditions.