CommencerCommencer gratuitement

Grading

In your school, students get their grades online. You want to make sure that students get complimented when strictly above 11, but also that they get a clear message when it is failed. The grades go from 0 to 20, and 10 is the passing grade.

Cet exercice fait partie du cours

Intermediate Java

Afficher le cours

Instructions

  • Use the correct operator and number to make sure that grades strictly above 11 get a compliment.
  • Use the correct keywords to make sure that it is entered only if the previous condition is false and something else is met.
  • Use the proper keyword to catch all other cases.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

class Grader {
  public static void main(String[] args) {
    int grade = 14;

    // Check if the grade is above 11
    if (grade ____ ____) {
      System.out.println("You've outdone yourself");
      // If the above condition is not met, check if the grade is at least 10
    } ____ ____ (grade >= 10) {
      System.out.println("You get a passing grade");
      // Add the correct keyword to grab every other possible case
    } ____ {
      System.out.println("You get a failing grade");
    }
  }
}
Modifier et exécuter le code