返回列表 發帖
本帖最後由 陳柏銓 於 2019-9-7 14:05 編輯
  1. import java.io.Console;
  2. public class C02 {

  3.         public static void main(String[] args) {
  4.                 int a;
  5.                 Console c=System.console();
  6.                 System.out.println("豬有幾隻腳? (1)一隻   (2)兩隻   (3)三隻   (4)四隻");
  7.                 a=Integer.parseInt(c.readLine("作答: "));
  8.                 switch(a)
  9.                 {
  10.                 case 1:
  11.                 System.out.println("怎麼可能? 用跳的嗎?!");
  12.                 break;
  13.                 case 2:
  14.                 System.out.println("沒吃過豬肉也看過豬走路!");
  15.                 break;
  16.                 case 3:
  17.                 System.out.println("你是豬啊?");
  18.                 break;
  19.                 case 4:
  20.                 System.out.println("答對了!");
  21.                 break;
  22.                 default:
  23.                 System.out.println("輸入錯誤");
  24.                 }
  25.         }

  26. }
複製代碼

TOP

返回列表