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


  2. public class ch01 {

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

TOP

返回列表