MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Intermediate Java

Lihat Kursus

Petunjuk latihan

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

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

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");
    }
  }
}
Edit dan Jalankan Kode