返回列表 發帖
  1. package ch01;

  2. import java.util.Scanner;
  3. public class ch01 {

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

TOP

返回列表