返回列表 發帖

[模擬考]TQC+ 210

完成TQC+ 210 題目

  1. import java.util.*;
  2. class JPA02 {
  3.     static Scanner keyboard = new Scanner(System.in);
  4.     public static void main(String[] args) {
  5.         test();
  6.         test();
  7.         test();
  8.         test();
  9.         test();
  10.     }
  11.   
  12.     public static void test() {
  13.             System.out.println("Input a character:");
  14.         String a = keyboard.nextLine();
  15.         switch(a)
  16.         {
  17.         case"a":
  18.                 System.out.println("You entered a or b");
  19.                 break;
  20.         case"b":
  21.                 System.out.println("You entered a or b");
  22.                 break;      
  23.         case"x":
  24.                 System.out.println("You entered x");
  25.                 break;
  26.         case"y":
  27.                 System.out.println("You entered y");
  28.                 break;
  29.         default:
  30.                 System.out.println("You entered something else");
  31.                 break;
  32.         }
  33.     }
  34. }
複製代碼

TOP

返回列表