- import java.io.*;
- import java.util.*;
- public class TQC110 {
- public static void main(String arg[]) {
- int userItemCoount = arg.length / 2;
- Boolean isUserItem = (userItemCoount > 0);
- String itemQue[];
- String itemAns[];
- if (isUserItem) {
- itemQue = new String[userItemCoount];
- itemAns = new String[userItemCoount];
- for (int i = 0; i < arg.length; i += 2) {
- itemQue[i / 2] = arg[i];
- itemAns[i / 2] = arg[i + 1];
- }
- } else {
- itemQue = new String[] { "電腦", "資料庫", "語法", "學校", "假期" };
- itemAns = new String[] { "computer", "database", "syntax",
- "school", "Vocation" };
- }
- long startTime = new Date().getTime();
- System.out.println("請將題目的中文字彙翻譯成英文單字!");
- System.out.println("輸入英文單字答案後請按Enter鍵:\n");
- Scanner scanner = new Scanner(System.in);
- int Right = 0;
- for (int i = 0; i < itemQue.length; i++) {
- System.out.println("第" + (i + 1) + "題__ " + itemQue[i]);
- String useInput = scanner.next();
- String ans = itemAns[i].toLowerCase();
- useInput = useInput.toLowerCase();
- if (useInput.equals(ans)) {
- System.out.println("答對了!");
- Right++;
- } else {
- System.out.println("答錯了!");
- System.out.println("正確答案是" + itemAns[i] + "\n");
- }
- }
- long endTime = new Date().getTime();
- long useTime = (endTime - startTime) / 1000;
- System.out.println("你使用了" + useTime + "秒,在" + itemQue.length + "題中答對了"
- + Right + "題");
- }
- }
複製代碼 |