// Zorah Fung, CSE 142 // An example of nested if/else if/else import java.util.*; public class Grades { public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.print("What percentage did you earn? "); int percent = console.nextInt(); if (percent >= 90) { System.out.println("You got an A!"); } else if (percent >= 80) { // percent < 90 is implied since the previous test failed System.out.println("You got a B!"); } else if (percent >= 70) { System.out.println("You got a C!"); } else if (percent >= 60) { System.out.println("You got a D!"); } else { // percent < 60 System.out.println("You got an F!"); } // Note: We use an if/else if/else structure because every student should receive // exactly one grade } }