標題:
TQC110 - 單字測驗
[打印本頁]
作者:
tonyh
時間:
2013-5-25 17:18
標題:
TQC110 - 單字測驗
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+"題");
}
}
複製代碼
作者:
t3742238
時間:
2013-5-25 17:25
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];
q[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鍵");
long start=new Date().getTime();
for(int i=0; i<q.length;i++)
{
System.out.println("第"+(i+1)+"題_ "+q[i]);
String answer=s.next();
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+"題");
}
}
複製代碼
作者:
劉漢文
時間:
2013-5-25 17:28
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];
q[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鍵");
long start=new Date().getTime();
for(int i=0; i<q.length;i++)
{
System.out.println("第"+(i+1)+"題_ "+q[i]);
String answer=s.next();
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+"題");
}
}
複製代碼
作者:
黃博鴻
時間:
2013-5-25 17:33
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.print("第"+(i+1)+"題_ "+q[i]+"\n");
String answer;
answer=s.next().toLowerCase();
if(answer.equals(a[i])==true)
{
System.out.println("答對了!\n");
sum++;
}else
{
System.out.println("答錯了!\n");
System.out.println("正確答案是"+a[i]+"\n");
}
}
long end=new Date().getTime();
System.out.println("你使用了"+(end-start)/1000+"秒,在"+q.length+"題中答對了"+sum+"題");
}
}
複製代碼
作者:
t2364705
時間:
2013-5-25 17:34
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","datebase","syntax","school","vocation"};
}
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+" 題");
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2