開始使用免費開始

再評一些成績

大家對客製化訊息很滿意,因此主管機關希望你把系統再做得更完善。學校有一套評語制度,以 2 分為一級,從 10 分開始。你被要求確保能在程式碼中及早偵測到不及格的學生。

本練習屬於課程

Java 中級

檢視課程

練習說明

  • 及早抓出低於 10 的不及格成績。
  • 填入正確的關鍵字,捕捉低於 18 的成績。
  • 確保其他所有成績都收到 "With highest distinction"

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

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

        // Catch failing grades lower than 10
        if (grade < 10) {
            System.out.println("Failing grade");
        } else if (grade < 14) {
            System.out.println("Passing grade");
        // Fill in the correct keyword    
        } ____ ____ (grade ____ ____) {
            System.out.println("With distinction");
        // Fill in the correct keyword    
        } ____ {
            System.out.println("With highest distinction");
        }
    }
}
編輯並執行程式碼