- import java.util.Scanner;
- public class Ch01 {
- public static void main(String[] args) {
- Scanner s=new Scanner(System.in);
- int ans;
- System.out.println("腦筋急轉彎:");
- System.out.println("請問豬有幾隻腳? (1) 一隻 (2) 兩隻 (3) 三隻 (4) 四隻");
- System.out.print("請回答: ");
- ans= s.nextInt();
- switch(ans)
- {
- case 1:
- System.out.println("用跳的嗎?");
- break;
- case 2:
- System.out.println("what?");
- break;
- case 3:
- System.out.println("wow?");
- break;
- case 4:
- System.out.println("GJ!");
- break;
- default:
- System.out.println("輸入錯誤!");
- }
- }
- }
複製代碼 |