- package hello;
- import java.util.Scanner;
- public class hello {
- public static void main(String[] args) {
- String ans;
- Scanner s=new Scanner(System.in);
- System.out.println("<腦殘>");
- while(true)
- {
- System.out.println("請問豬有幾隻腳?(A)一隻(B)兩隻(C)三隻(D)四隻");
- System.out.print("請回答: ");
- ans=s.nextLine();
- switch(ans)
- {
- case "A":
- System.out.println("殘障豬是嗎?");
- break;
- case "B":
- System.out.println("可憐哪~");
- break;
- case "C":
- System.out.println("總目標是發大財!");
- break;
- case "D":
- System.out.println("正確?");
- break;
-
- default:
- System.out.println("輸入錯誤");
- }
- }
- }
- }
複製代碼 |