Java Lesson 6: If-Else-If Statements


  • If-else-if statements allow you to test out a series of conditions, this is easier than to do nested if-else statements.
  • Example would be:
     if (avg <60){
                System.out.println(“Your grade is  F.”);
            else if (avg < 70){
                System.out.println(“Your grade is  D.”);
            else if (avg < 80){
                System.out.println(“Your grade is C.”);
            else if (avg < 90){
                System.out.println(“Your score is B.”);
                System.out.println(“Your score is A.”);

View the Code!