Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Intermediate Java

Cursus bekijken

Oefeninstructies

  • 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.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

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");
    }
  }
}
Code bewerken en uitvoeren