本帖最後由 鄭繼威 於 2023-5-3 21:01 編輯


雙向判斷式語法
if (條件式或布林值){
程式區塊一;
}
else{
程式區塊二;
}
- import java.io.Console;
- public class Ch08
- {
- public static void main(String args[])
- {
- Console c=System.console();
- int age;
- System.out.print("輸入年紀: ");
- age=Integer.parseInt(c.readLine());
- if(age>=18)
- System.out.println("可以考駕照了!");
- else
- System.out.println("再等等~~");
- }
- }
複製代碼 |