- import java.io.Console;
- public class Ch01
- {
- public static void main(String args[])
- {
- Console c=System.console();
- int a;
- System.out.println("豬有幾隻腳? (1)一隻(2)兩隻(3)三隻(4)四隻");
- System.out.print("請作答: ");
- 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(". . .");
- }
- }
- }
複製代碼 |