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]);
- }
- }
- }
複製代碼 |