標題:
TQC110 ~ TQC03做好的上傳
[打印本頁]
作者:
TOM
時間:
2012-7-21 10:47
標題:
TQC110 ~ TQC03做好的上傳
做好的上傳,謝謝
作者:
TOM
時間:
2012-7-21 10:49
110
import java.util.*;
public class tqc110 {
public static void main(String[] args) {
int userIs = args.length/2;
boolean isuser =(userIs>0);
String[] q;
String[] a;
if(isuser)
{
q=new String[userIs];
a=new String[userIs];
for(int i=0;i<args.length;i+=2)
{
q[i/2]=args[i];
a[i/2]=args[i+1];
}
}else
{
q=new String[]{"電腦","資料庫","語法","學校","假期"};
a=new String[]{"computer","DataBase","syntax","School","Vocation"};
}
long startTime = new Date().getTime();
System.out.println("請將下列中文詞彙換成英文單字!");
System.out.println("輸入完成後請按Enter鍵:");
Scanner s=new Scanner(System.in);
int right =0;
for(int i=0;i<q.length;i++)
{
System.out.println("第"+(i+1)+"題_"+q[i]);
String user=s.next();
user.toLowerCase();
String ans =a[i].toLowerCase();
if(user.equals(ans))
{
System.out.println("Right!!");
right++;
}else
{
System.out.println("No!!");
System.out.println("正確答案是:"+a[i]);
}
System.out.println();
}
long endTime = new Date().getTime();
long use = (endTime-startTime)/1000;
System.out.println("你使用了"+use+"秒,在"+q.length+"題中答對了"+right+"題");
}
}
複製代碼
201
import java.util.*;
public class tqc201 {
public static void main(String[] args) {
Scanner s =new Scanner(System.in);
System.out.print("請輸入Z的最大值");
int z=Integer.parseInt(s.next());
int temp = 0;
for(int x=1;x<100000;x++)
{
int y = 3*(x*x)+2*x+1;
if(y>z)
{
System.out.println("當X ="+(x-1)+"時, Y ="+temp+",Z="+z+",符合 Y > Z 的條件");
break;
}
temp=y;
}
}
}
複製代碼
202
public class java202 {
public static void main(String[] args) {
float p = 1000;
double r = 0.05 ;
int n = 10 ;
System.out.println("年"+"\t"+"A銀行(複利)"+"\t"+"B銀行(單利)");
for(int i=1;i<=n;i++)
{
float m1=(float)(p*Math.pow(1+r,i));
float m2=(float)(p*(1+i*r));
System.out.printf("%d\t%.0f\t\t%.0f\n",i,m1,m2);
}
}
}
複製代碼
203
import java.util.*;
public class tqc203 {
public static void main(String[] args) {
if(args.length!=1)
{
System.out.println("參數戒務");
return ;
}
String str[] = args[0].split(",");
System.out.println("隔開的字數是"+str.length);
for(int i=0;i<str.length;i++)
{
System.out.println( (i+1)+","+str[i]);
}
}
}
複製代碼
作者:
lon
時間:
2012-7-21 11:45
import java.util.*;
public class jva110 {
public static void main(String[] arg) {
int userItemCount=arg.length/2;
boolean isUserItem=(userItemCount>0);
String[] itemQue;
String[] itemAns;
if(isUserItem){
itemQue=new String[userItemCount];
itemAns=new String[userItemCount];
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"};
userItemCount = itemQue.length;
}
long start=new Date().getTime();
System.out.println("請將下列中文詞彙轉換成英文單字!");
System.out.println("輸入完成後請按Enter鍵:");
Scanner s=new Scanner(System.in);
int right = 0;
for(int i=0;i<userItemCount;i++){
System.out.println("第"+(i+1)+"題_"+itemQue[i]);
String userInput=s.next();
userInput=userInput.toLowerCase();
String ans=itemAns[i].toLowerCase();
if(userInput.equals(ans)){
System.out.println("答對了!");
right++;
}else{
System.out.println("答錯了!");
System.out.println("正確答案是"+itemAns[i]+"!");
}
System.out.println();
}
long end=new Date().getTime();
long use=(end-start)/1000;
System.out.println("您使用了"+use+"秒,在"+userItemCount+"題中答對了"+right+"題!");
}
}
複製代碼
import java.util.*;
public class jva201 {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
System.out.println("請輸入Z可能的最大值:");
int z=Integer.parseInt(s.next());
int temp;
for(int x=1;x<100000;x++){
int y=3*(x*x)+2*x+1;
if(y<z){
System.out.println("當x="+x+"時,Y="+y+",Z="+z+",符合Y<Z的條件");
}
break;
}
}
}
複製代碼
public class jva202 {
public static void main(String[] args) {
float m=1000;
double r=0.05;
int n=10;
System.out.println("年\tA銀行(複利)\tB銀行(單利)");
for(int i=1;i<=n;i++){
float m1=(float)(m*Math.pow(1+r,i));
float m2=(float)(m*(1+i*r));
System.out.printf("%d\t%.0f\t\t%.0f\n",i,m1,m2);
}
}
}
複製代碼
import java.util.*;
public class jva203 {
public static void main(String[] arg) {
if(arg.length!=1){
System.out.println("參數借誤!參數中不得有空白或必須以逗號隔開!");
return;
}
String[] str=arg[0].split(",");
System.out.println("逗號隔開的字數共有:"+str.length);
for(int i=0;i<str.length;i++){
System.out.println((i+1)+"."+str[i]);
}
}
}
複製代碼
作者:
johnson
時間:
2012-7-21 11:53
import java.util.Date;
import java.util.Scanner;
public class TQC110 {
public static void main(String[] args) {
int userItemCoount = args.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 < args.length; i += 2) {
itemQue[i / 2] = args[i];
itemAns[i / 2] = args[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 + "題");
}
}
複製代碼
import java.util.*;
public class TQC201 {
public static void main(String arg[]) {
Scanner s = new Scanner(System.in);
System.out.print("請輸入Z可能的最大值:");
int z = Integer.parseInt(s.next());
int temp;
for (int x = 1; x <= 10; x++) {
int y = x * x * 3 + x * 2 + 1;
if (y < z) {
System.out.printf("x=%d,Y=%d,Z=%d,符合Y<Z的條件");
break;
}
temp = y;
}
}
}
複製代碼
public class TQC202 {
public static void main(String arg[]) {
int p = 1000;
double r = 0.05;
int n = 10;
System.out.println("年\t A銀行(複利) \t B銀行(單利)");
System.out.println("-------------------------------");
for (int i = 1; i <= n; i++) {
int m1 = (int) (p * Math.pow(1 + r, i));
int m2 = (int) (p * (1 + i * r));
System.out.printf("%d\t%d\t\t%d\n", i, m1, m2);
}
System.out.println("-------------------------------");
}
}
複製代碼
import java.util.*;
public class TQC203{
public static void main(String arg[]){
if(arg.length!=1){
System.out.println("參數借誤!字串中不得有空白或必須以逗號隔開!");
return ;
}
String str[] = arg[0].split(",");
System.out.println("逗號隔開的字串個數共有: "+str.length);
for(int i=0;i<str.length;i++){
System.out.println( (i+1)+"."+str[i] );
}
}
}
複製代碼
作者:
kim
時間:
2012-7-21 11:55
TQC110
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 + "題");
}
}
複製代碼
TQC201
import java.util.*;
public class TQC201
{
public static void main(String arg[])
{
Scanner s = new Scanner(System.in);
System.out.print("請輸入 Z 可能的最大值:");
long z = Integer.parseInt(s.next());
long tot=0;
for(long x=1;x<=100000;x++)
{
long y = 3 * (x*x) + x*2 +1 ;
if(y>z)
{
System.out.printf("當 x =%d 時, Y =%d , Z =%d,符合 Y < Z 的條件",x-1,tot,z);
break;
}
tot=y ;
}
}
}
複製代碼
TQC202
public class TQC202
{
public static void main(String[] args)
{
System.out.println("年\tA銀行(複利)\tB銀行(單利)");
System.out.println("-------------------------------------");
int p=1000;
double r=0.05;
int n=10;
for(int i=1;i<=n;i++)
{
int m1=(int)(p*Math.pow(1+r,i));
int m2=(int)(p*(1+i*r));
System.out.printf("%d\t%d\t%d\n",i,m1,m2);
}
}
}
複製代碼
TQC203
import java.util.*;
public class TQC203 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
if(args.length!=1)
{
System.out.println("參數錯誤!字串中不得有空白或必須以逗號隔開");
return;
}
String str[]=args[0].split(",");
System.out.println("逗號隔開的字串個數共有:"+str.length);
for(int i=0;i<str.length;i++)
{
System.out.println((i+1)+"."+str[i]);
}
}
}
複製代碼
作者:
許逸瑋
時間:
2012-7-21 11:58
import java.io.*;
public class JVA201
{
TQC201() {}
public static void main(String args[]) throws Exception
{
int x,y,z;
int x0,y0;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("請輸入 Z 可能的最大值:");
z = Integer.parseInt( br.readLine() );
if(z>1){
x = -1; y=0;
do{
x0=x;
y0=y;
x++;
y=(int)(Math.pow(x,2)*3+2*x+1.0);
}while(y<z);
System.out.println("當 X = " + x0 +"時, Y = " + y0 + ", Z = " + z +",符合 Y < Z 的條件");
}else{
System.out.println("當 X,Y 為正整數時, Y 恆大於等於 1, 故 Z = " + z +",無符合 Y < Z 的最佳解");
}
}
}
複製代碼
作者:
許逸瑋
時間:
2012-7-21 12:03
public class TQC202
{
public static void main(String args[])
{
double r=0.05;
int p = 1000;
int n = 10;
int m1,m2;
System.out.println("年 A銀行(複利) B銀行(單利)");
System.out.println("----------------------------------------");
for(int i = 1; i <= n ; i++)
{
m1 = (int)(p * Math.pow( (1+r) , i ));
m2 = (int)(p * ( 1 + r*i ));
System.out.printf("%d\t%d\t\t%d\n",i,m1,m2);
}
System.out.println("----------------------------------------");
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2