- import java.util.*;
- class TQC110{
-
- static Date d;
- static long start, end;
-
- public static void main(String args[]){
- Scanner in = new Scanner(System.in);
- String[][] items;
-
- if(args.length == 0){
- items = new String[5][2];
- items[0][0] = "電腦"; items[0][1] = "computer";
- items[1][0] = "資料庫";items[1][1] = "database";
- items[2][0] = "語法";items[2][1] = "syntax";
- items[3][0] = "學校";items[3][1] = "school";
- items[4][0] = "假期";items[4][1] = "vacation";
- }else{
- items = new String[args.length/2][2];
- for(int i = 0; i < args.length; i++){
- if(i%2 == 0)
- items[i/2][0] = args[i];
- else
- items[(int)i/2][1] = args[i];
- }
-
- }
-
- int correct = 0;
- d = new Date();
- start = d.getTime();
- System.out.println("請將題目的中文詞彙翻譯成英文單字!");
- System.out.println("輸入英文單字答案後請按Enter鍵:");
- System.out.println(" ");
-
- for(int i = 0; i < items.length; i++){
- System.out.println("第" + (i + 1) + "題__ " + items[i][0]);
- String userAns = in.nextLine();
- if(userAns.equalsIgnoreCase(items[i][1])){
- correct++;
- System.out.println("答對了!");
- }else{
- System.out.printf("答錯了!\n正確答案是%s\n", items[i][1]);
- }
- }
-
- d = new Date();
- end = d.getTime();
- System.out.print("你使用了" + (end - start) / 1000L + "秒, 在");
- System.out.println(items.length + "題中答對了" + correct + "題");
-
- }
- }
複製代碼 |