- import java.util.Scanner;
- public class Ch11 {
- public static void main(String[] args) {
- Scanner s=new Scanner(System.in);
- String ans;
- System.out.println("<腦殘問答>");
- while(true)
- {
- System.out.println("請問豬有幾隻腳?(A)1 (B)2 (C)3 (D)4");
- System.out.println("請作答:");
- ans=s.nextLine();
- switch(ans)
- {
- case "A":
- case "a":
- case "1":
- System.out.println("用跳的嗎?");
- break;
- case "B":
- case "b":
- case "2":
- System.out.println("沒吃過豬肉也看過豬走路!");
- break;
- case "C":
- case "c":
- case "3":
- System.out.println("你是豬啊?");
- break;
- case "D":
- case "d":
- case "4":
- System.out.println("答對了!");
- break;
- default:
- System.out.println("輸入錯誤");
-
-
- }
-
- }
- }
- }
複製代碼 |