返回列表 發帖
本帖最後由 何蕙妘 於 2020-1-31 15:37 編輯
  1. import java.util.Scanner;
  2. public class ch44
  3. {
  4.         public static void main(String args[])
  5.     {
  6.                 Scanner s=new Scanner(System.in);
  7.                 int a;
  8.                 System.out.println("<有趣問答>");
  9.                 System.out.println("請問豬有幾隻腳?(1)一隻(2)兩隻(3)三隻(4)四隻");
  10.                 System.out.print("請回答: ");
  11.                 a=s.nextInt();
  12.                 switch (a) {
  13.                 case 1:
  14.                         System.out.print("你的豬是哪個世界的?");
  15.                         break;
  16.                 case 2:
  17.                         System.out.print("是你?");
  18.                         break;
  19.                 case 3:
  20.                         System.out.print("你有沒有送牠去醫院?");
  21.                         break;
  22.                 case 4:
  23.                         System.out.print("基本常識");
  24.                         break;       
  25.                 default:
  26.                         System.out.print("要記得去看眼科");
  27.                         break;
  28.                 }
  29.     }
  30. }
複製代碼

TOP

返回列表