本帖最後由 陳柏銓 於 2019-9-7 14:05 編輯
- import java.io.Console;
- public class C02 {
- public static void main(String[] args) {
- int a;
- Console c=System.console();
- System.out.println("豬有幾隻腳? (1)一隻 (2)兩隻 (3)三隻 (4)四隻");
- a=Integer.parseInt(c.readLine("作答: "));
- switch(a)
- {
- case 1:
- System.out.println("怎麼可能? 用跳的嗎?!");
- break;
- case 2:
- System.out.println("沒吃過豬肉也看過豬走路!");
- break;
- case 3:
- System.out.println("你是豬啊?");
- break;
- case 4:
- System.out.println("答對了!");
- break;
- default:
- System.out.println("輸入錯誤");
- }
- }
- }
複製代碼 |