返回列表 發帖
  1. import java.util.Scanner;
  2. public class Ch01
  3. {
  4.         public static void main(String[] args)
  5.         {
  6.                 while(true)
  7.                 {       
  8.                         int answer;
  9.                         Scanner s=new Scanner(System.in);
  10.                         System.out.println("<小明的腦殘問答>");
  11.                         System.out.println("請問豬有幾隻腳?<1>一隻<2>兩隻<3>三隻<4>四隻");
  12.                         System.out.print("請回答: ");
  13.                         answer=s.nextInt();
  14.                 switch(answer)
  15.                 {
  16.                     case 1:
  17.                             System.out.println("用跳的嗎?");
  18.                             break;
  19.                     case 2:
  20.                             System.out.println("沒吃過豬肉也看過豬走路!");
  21.                             break;
  22.                     case 3:       
  23.                         System.out.println("你是豬啊?");
  24.                         break;
  25.                     case 4:
  26.                             System.out.println("恭喜你 答對了!");
  27.                             break;
  28.                     default:
  29.                             System.out.println("輸入錯誤");
  30.                 }
  31.                 }
  32.         }
  33. }
複製代碼

TOP

返回列表