返回列表 發帖
本帖最後由 孫焌仁 於 2019-1-23 09:50 編輯
  1. import java.util.Scanner;


  2. public class Ch10 {

  3.         public static void main(String[] args) {
  4.                 Scanner s=new Scanner(System.in);
  5.                 int ans;
  6.         System.out.println("<小米的腦殘問答>");
  7.         System.out.println("請問豬有幾隻腳?(1)一隻(2)兩隻(3)三隻(4)四隻");
  8.         System.out.print("請回答:");
  9.         ans=s.nextInt();
  10.         switch(ans)
  11.         {
  12.                         case 1:
  13.                         System.out.println("用跳的嗎?");
  14.                         break;
  15.                         case 2:
  16.                         System.out.println("沒吃過豬肉也看過豬走路!");
  17.                         break;
  18.                         case 3:
  19.                         System.out.println("你是豬啊?");
  20.                         break;
  21.                         case 4:
  22.                         System.out.println("答對了!");
  23.                         break;
  24.                         default:
  25.                               System.out.println("輸入錯誤!");
  26.         }   
  27.         }

  28. }
複製代碼

TOP

返回列表