- import java.util.Scanner;
- public class Ch10 {
- public static void main(String[] args) {
- int amswer;
- Scanner s=new Scanner( System.in);
- while(true)
- {System.out.println("問答");
- System.out.println("請問豬有幾隻腳(1)一隻(2)兩隻(3)三隻(4)四隻?");
-
-
- amswer=s.nextInt();
- switch (amswer)
- {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("輸入錯誤");
-
- }
- }
-
- }
- }
複製代碼 |