返回列表 發帖
本帖最後由 湯郡一 於 2019-9-7 14:12 編輯
  1. import java.io.Console;
  2. public class ch01;
  3. {
  4.   public.static void main(String args[])
  5.   {
  6.   Console c=System.Console();
  7.   int ans;
  8.   System.out.println("豬有幾隻腳(1)一隻(2)兩隻(3)三隻(4)四隻");
  9.   System.out.print("作答: ");
  10.   ans=Integer.parseInt(c.readLine());
  11.   switch(ans)
  12.   {
  13.      case 1:
  14.          System.out.println("怎麼可能? 用跳的嗎?");
  15.          break;
  16.      case 2:
  17.          System.out.println("你是豬啊?");
  18.          break;
  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. }
複製代碼

TOP

返回列表