返回列表 發帖
  1. import java.io.Console;
  2. public class Ch11
  3. {
  4.     public static void main(String agrs[])
  5.     {
  6.          int ans;
  7.          Console c=System.console();
  8.          System.out.println("<問題>');
  9.          System.out.println("請問豬有幾隻腳?  (1)1 (2)2 (3)3 (4)4");
  10.          System.out.println("請作答: ");
  11.          opt=Integer.parseInt(c.readLine());
  12.          switch(opt)
  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. }
複製代碼

TOP

返回列表