210 鍵盤字元判斷
import java.util.*;
class JPA210 {
static Scanner keyboard = new Scanner(System.in);
public static void main(String[] args) {
test();
test();
test();
test();
test();
}
public static void test() {
String s;
System.out.println("Input a character :");
s=keyboard.next();
switch(s){
case "a":
case "b":
System.out.println("You entered a or b");break;
case "x":
System.out.println("You entered x");break;
case "y":
System.out.println("You entered y");break;
default:
System.out.println("You entered something else.");break;
}
}
}
沒有留言:
張貼留言