返回列表 發帖
  1. import java.util.Scanner;

  2. public class Hw {

  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.println("請回答: ");
  9.                 ans = s.nextInt();
  10.                 switch(ans) {
  11.                 case 1:
  12.                         System.out.println("用跳的嗎?");
  13.                         break;
  14.                 case 2:
  15.                         System.out.println("沒吃過豬肉也看過豬走路!");
  16.                         break;
  17.                 case 3:
  18.                         System.out.println("你是豬啊");
  19.                         break;
  20.                 case 4:
  21.                         System.out.println("答對了!");
  22.                         break;
  23.                 default:
  24.                         System.out.println("輸入錯誤");
  25.                 }
  26.         }

  27. }
複製代碼

TOP

返回列表