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

TOP

返回列表