/****** 檔名:JPA02.java 題目:TQC+ JAVA6物件導向程式設計 參考答案 時間:2015/06 作者:fang shi mai ******/ import java.util.*; public class JPA02 { static Scanner keyboard = new Scanner(System.in); public static void main(String[] args) { test(); test(); test(); test(); test(); } public static void test() { String N; char ch; System.out.println("Input a character:"); N=keyboard.next(); ch=N.charAt(0); switch(ch) { case 'a': System.out.println("You entered a or b"); break; 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; } } }
210鍵盤字元判斷
訂閱:
文章 (Atom)
沒有留言:
張貼留言