- import java.io.Console;
- public class Ch11
- {
- public static void main(String agrs[])
- {
- int ans;
- Console c=System.console();
- System.out.println("<問題>');
- System.out.println("請問豬有幾隻腳? (1)1 (2)2 (3)3 (4)4");
- System.out.println("請作答: ");
- opt=Integer.parseInt(c.readLine());
- switch(opt)
- {
- 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("輸入錯誤!");
- }
- }
- }
複製代碼 |