開始使用免費開始

超過 9000 的功率

你正在工廠裡讀取萬用電錶的功率讀數。你必須確保一旦數值超過 9000,大家都會知道。否則就不用有任何動作。

本練習屬於課程

Java 中級

檢視課程

練習說明

  • 輸入可用來檢查條件是否為真的關鍵字 if
  • 使用正確的運算子,只在數值大於 9000 時顯示文字。

動手互動練習

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

class PowerChecker {
  public static void main(String[] args) {
    int power = 9000;

    // Write down the right keyword to make this a condition and use the correct operation
    ____ (power ____ 9000) {
      System.out.println("It's over 9000 !");
    }
  }
}
編輯並執行程式碼