本帖最後由 何蕙妘 於 2020-1-31 15:37 編輯
- import java.util.Scanner;
- public class ch44
- {
- public static void main(String args[])
- {
- Scanner s=new Scanner(System.in);
- int a;
- System.out.println("<有趣問答>");
- System.out.println("請問豬有幾隻腳?(1)一隻(2)兩隻(3)三隻(4)四隻");
- System.out.print("請回答: ");
- a=s.nextInt();
- switch (a) {
- case 1:
- System.out.print("你的豬是哪個世界的?");
- break;
- case 2:
- System.out.print("是你?");
- break;
- case 3:
- System.out.print("你有沒有送牠去醫院?");
- break;
- case 4:
- System.out.print("基本常識");
- break;
- default:
- System.out.print("要記得去看眼科");
- break;
- }
- }
- }
複製代碼 |