- import java.util.*;
- public class tqc110
- {
- public static void main(String args[])
- {
- Scanner s=new Scanner(System.in);
- int sum=0;
- String q[], a[];
- if(args.length>=2 && args.length%2==0)
- {
- q=new String[args.length/2];
- a=new String[args.length/2];
- for(int i=0; i<args.length; i+=2)
- {
- q[i/2]=args[i];
- a[i/2]=args[i+1].toLowerCase();
- }
- }else
- {
- q=new String[]{"電腦","資料庫","語法","學校","假期"};
- a=new String[]{"computer","database","syntax","school","vacation"};
- }
- System.out.println("請將題目的中文詞彙翻譯成英文單字!");
- System.out.println("輸入英文單字答案後請按Enter鍵:\n");
- long start=new Date().getTime();
- for(int i=0; i<q.length; i++)
- {
- System.out.println("第"+(i+1)+"題_"+q[i]);
- String answer=s.next().toLowerCase();
- if(answer.equals(a[i])==true)
- {
- System.out.println("答對了!\n");
- sum++;
- }else
- {
- System.out.println("答錯了!");
- System.out.println("正確答案是"+a[i]+"\n");
- }
- }
- long end=new Date().getTime();
- System.out.println("您共使用了"+(end-start)/1000+"秒, 在"+q.length+"題中答對了"+sum+"題");
- }
- }
複製代碼 |