返回列表 發帖
  1. import java.util.Scanner;


  2. public class Ch10 {

  3.         public static void main(String[] args) {
  4.                 Scanner s=new Scanner(System.in);
  5.                 String ans;
  6.                 System.out.println("<腦殘問答>");
  7.                 while(ture){
  8.                         System.out.println("請問豬有幾隻腳: (A)一隻 (B)兩隻 (C)三隻 (D)四隻");
  9.                         System.out.print("請回答: ");
  10.                         ans=s.nextLine();
  11.                         switch(ans)
  12.                         {
  13.                         case"A":
  14.                         case"a":
  15.                         case"1":
  16.                                 System.out.println("用跳的嗎?");
  17.                                 break;
  18.                         case"B":
  19.                         case"b":
  20.                         case"2":
  21.                                 System.out.println("沒吃過豬肉也看過豬走路!");
  22.                                 break;
  23.                         case"C":
  24.                         case"c":
  25.                         case"3":
  26.                                 System.out.println("你是豬啊?");
  27.                                 break;
  28.                         case"D":
  29.                         case"d":
  30.                         case"4":
  31.                                 System.out.println("答對了!");
  32.                                 break;
  33.                                 default;
  34.                                 System.out.println("輸入錯誤!");

  35.                         }
  36.                 }
  37.         }

  38. }
複製代碼

TOP

返回列表