返回列表 發帖
  1. import java.util.Scanner;
  2. public class Ch10
  3. {
  4.         public static void main(String[] args)
  5.         {
  6.                 Scanner s=new Scanner(System.in);
  7.                 int ans;
  8.                 System.out.println("<No Brainer Question>");
  9.                 System.out.println("How many legs does a pig have?\n(1)ONE (2)TWO (3)THREE (4)FOUR");
  10.                 System.out.print("Your Answer: ");
  11.                 ans=s.nextInt();
  12.                 switch(ans)
  13.                 {
  14.                     case 1:
  15.                             System.out.println("WRONG!!");
  16.                             break;
  17.                     case 2:
  18.                             System.out.println("WRONG!!");
  19.                             break;
  20.                     case 3:
  21.                             System.out.println("WRONG!!");
  22.                             break;
  23.                     case 4:
  24.                             System.out.println("Well you are SMART~~");
  25.                             break;
  26.                     default:
  27.                             System.out.println("ERROR!!!");
  28.                 }

  29.         }

  30. }
複製代碼

TOP

返回列表