- import java.io.Console;
- public class Ch13
- {
- public static void main(String args[])
- {
- Console c=System.console();
- int opt; //option
- System.out.println("豬有幾隻腳? (1)一隻 (2)兩隻 (3)三隻 (4)四隻 ");
- System.out.print("作答: ");
- opt=Integer.parseInt(c.readLine());
- switch(opt)
- {
- case 1:
- System.out.println("???");
- break;
- case 2:
- System.out.println("???");
- break;
- case 3:
- System.out.println("???");
- break;
- case 4:
- System.out.println("正確答案");
- break;
- default:
- System.out.println("輸入錯誤!");
- }
- }
- }
複製代碼 |