- package ch01;
- import java.util.Scanner;
- public class ch01 {
- public static void main(String[] args) {
- Scanner s=new Scanner(System.in);
- int answer;
- System.out.println("<動物問答>");
- System.out.println("請問狗有幾隻腳? (1)一隻 (2)兩隻 (3)三隻 (4)四隻 ");
- System.out.print("請回答: ");
- answer=s.nextInt();
- switch(answer)
- {
- case 1:
- System.out.println("狗用跳的嗎?");
- break;
- case 2:
- System.out.println("沒養過狗也看過狗1"+ "走路!");
-
- break;
- case 3:
- System.out.println("你是豬啊?");
- break;
- case 4:
- System.out.println("答對了!");
- break;
- default:
- System.out.println("輸入錯誤!");
- }
- }
- }
複製代碼 |