標題:
110單字測驗(請大家把自己的程式PO上來)
[打印本頁]
作者:
ray
時間:
2012-1-7 20:25
標題:
110單字測驗(請大家把自己的程式PO上來)
import java.io.*;
import java.util.Date;
class TQC110
{
String items[][];
long start, end;
Date d;
BufferedReader br;
public static void main(String args[])
{
int total = args.length;
int pairs = total / 2;
TQC110 tte;
if(total != 0 && pairs != 0)
{
String[][] tt = new String[pairs][2];
for(int k = 0; k < pairs ; k++)
{
tt[k][0] = args[k * 2];
tt[k][1] = args[k * 2 + 1];
}
tte = new TQC110(tt);
}
else
tte = new TQC110();
tte.start();
}
TQC110()
{
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] = "Vocation";
br = new BufferedReader(new InputStreamReader(System.in));
}
TQC110(String[][] it)
{
items = it;
br = new BufferedReader(new InputStreamReader(System.in));
}
void start()
{
String ans = "";
int correct = 0; // 計算答對題數
d = new Date();
start = d.getTime(); // 開始答題時間
System.out.println("請將題目的中文詞彙翻譯成英文單字!");
System.out.println("輸入英文單字答案後請按Enter鍵:\n");
for(int j = 0; j < items.length ; j++)
{
System.out.println("第" + (j + 1) + "題__ " + items[j][0]);
try
{
ans = br.readLine();
}
catch(IOException ioexception)
{
System.out.println(ioexception);
}
if(ans.equalsIgnoreCase(items[j][1]))
{
correct++;
System.out.println("答對了 !\n");
}
else
{
System.out.println("答錯了 !");
System.out.println("正確答案是" + items[j][1] + "\n");
}
}
d = new Date();
end = d.getTime(); // 結束答題時間
System.out.print("你使用了" + (end - start) / 1000L + "秒, 在");
System.out.println(items.length + "題中答對了" + correct + "題");
}
}
作者:
chuangjoy
時間:
2012-1-17 22:00
import java.io.*;
import java.util.Date;
class TQC110{
String items[][];
long start, end;
Date d;
BufferedReader br;
public static void main(String args[]){
int total = args.length;
int pairs = total / 2;
TQC110 tte;
if(total != 0 && pairs != 0)
{
//get value from args..
String[][] tt = new String[pairs][2];
for(int i=0; i<pairs; i+=2){
tt[i][0] = args[i];
tt[i][1] = args[i+1];
}
tte = new TQC110(tt);
}else
tte = new TQC110();
tte.start();
}
TQC110(){
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";
//make default value
br = new BufferedReader(new InputStreamReader(System.in));
}
TQC110(String[][] it){
items = it;
br = new BufferedReader(new InputStreamReader(System.in));
}
void start(){
String ans = "";
int correct = 0; // 計算答對題數
d = new Date();
start = d.getTime(); // 開始答題時間
System.out.println("請將題目的中文詞彙翻譯成英文單字!");
System.out.println("輸入英文單字答案後請按Enter鍵:");
System.out.println(" ");
for(int j = 0; j < items.length ; j++)
{
System.out.println("第" + (j + 1) + "題__ " + items[j][0]);
try{
ans = br.readLine();
}
catch(IOException ioexception){
System.out.println(ioexception);
}
if(ans.equalsIgnoreCase(items[j][1])){
correct+=1;
System.out.println("答對了!");
//count correct
//ouput correct message
}else{
System.out.println("答錯了! 正確答案是:" + items[j][1]);
//ouput incorrect message
}
}
d = new Date();
end = d.getTime(); // 結束答題時間
System.out.print("你使用了" + (end - start) / 1000L + "秒, 在");
System.out.println(items.length + "題中答對了" + correct + "題");
}
}
複製代碼
作者:
p17johnny
時間:
2012-1-28 11:25
import java.io.*;
import java.util.Date;
class TQC110{
String items[][];
long start, end;
Date d;
BufferedReader br;
public static void main(String args[]){
int total = args.length;
int pairs = total / 2;
TQC110 tte;
if(total != 0 && pairs != 0)
{
//get value from args..
String[][] tt = new String[pairs][2];
for(int i=0; i<pairs; i+=2){
tt[i][0] = args[i];
tt[i][1] = args[i+1];
}
tte = new TQC110(tt);
}else
tte = new TQC110();
tte.start();
}
TQC110(){
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";
//make default value
br = new BufferedReader(new InputStreamReader(System.in));
}
TQC110(String[][] it){
items = it;
br = new BufferedReader(new InputStreamReader(System.in));
}
void start(){
String ans = "";
int correct = 0; // 計算答對題數
d = new Date();
start = d.getTime(); // 開始答題時間
System.out.println("請將題目的中文詞彙翻譯成英文單字!");
System.out.println("輸入英文單字答案後請按Enter鍵:");
System.out.println(" ");
for(int j = 0; j < items.length ; j++)
{
System.out.println("第" + (j + 1) + "題__ " + items[j][0]);
try{
ans = br.readLine();
}
catch(IOException ioexception){
System.out.println(ioexception);
}
if(ans.equalsIgnoreCase(items[j][1])){
correct+=1;
System.out.println("答對了!");
//count correct
//ouput correct message
}else{
System.out.println("答錯了! 正確答案是:" + items[j][1]);
//ouput incorrect message
}
}
d = new Date();
end = d.getTime(); // 結束答題時間
System.out.print("你使用了" + (end - start) / 1000L + "秒, 在");
System.out.println(items.length + "題中答對了" + correct + "題");
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2