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


  2. public class Ch10 {

  3.         public static void main(String[] args) {
  4.     int amswer;
  5.         Scanner s=new Scanner(        System.in);
  6.         while(true)
  7.         {System.out.println("問答");
  8.     System.out.println("請問豬有幾隻腳(1)一隻(2)兩隻(3)三隻(4)四隻?");

  9.        
  10.         amswer=s.nextInt();
  11.         switch (amswer)
  12.           {case 1:
  13.                   System.out.println("用跳的嗎?");
  14.                   break;
  15.           case 2:
  16.                   System.out.println("沒吃過豬肉也看過豬走路!");
  17.                   break;
  18.        
  19.           case 3:
  20.                   System.out.println("你是豬啊?");
  21.                   break;
  22.           case 4:
  23.                   System.out.println("答對了!");
  24.                   break;
  25.                   default:
  26.           System.out.println("輸入錯誤");         
  27.        
  28.           }
  29.         }
  30.        
  31.         }

  32. }
複製代碼

TOP

返回列表