int t[]={453,68,6768,78,89,56,34,87,3456,77};
請用為迴圈for, while, do-while計算他的平均。
39 則留言:
B10133029 彭義竣
提到...
// for int t[]={453,68,6768,78,89,56,34,87,3456,77}; double sum = 0; for (int i = 0; i < t.length; i += 1) { sum = sum + t[i]; } System.out.println(sum / t.length); // while int t[]={453,68,6768,78,89,56,34,87,3456,77}; double sum2 = 0; int i = 0; while (i < t.length) { sum2 = sum2 + t[i]; i = i + 1; } System.out.println(sum2 / t.length); // do-while int t[]={453,68,6768,78,89,56,34,87,3456,77}; double sum3 = 0; int i = 0; do { sum3 = sum3 + t[i]; i = i + 1; } while (i < t.length); System.out.println(sum3 / t.length);
/** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int t[]={67,66,87,65,98,97,65,55,69,59}; int sum=0; double av; for(int i=0; i<t.length; i++) sum+=t[i]; av=(double)sum/10; System.out.println(av); }
}
//////////
public class Ex3 {
/** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int t[]={67,66,87,65,98,97,65,55,69,59}; int sum=0; double av; int i=0; while(i<t.length){ sum+=t[i]; i++; } av=(double)sum/10; System.out.println(av);
}
}
///////////
public class Ex4 {
/** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub
int t[]={67,66,87,65,98,97,65,55,69,59}; int sum=0; double av; int i=0; do{ sum+=t[i]; i++; }while(i<t.length); av=(double)sum/10; System.out.println(av);
/** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int t[]={67,66,87,65,98,97,65,55,69,59}; int sum=0; double av; for(int i=0; i<t.length; i++) sum+=t[i]; av=(double)sum/10; System.out.println(av); }
}
//////////
public class Ex3 {
/** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int t[]={67,66,87,65,98,97,65,55,69,59}; int sum=0; double av; int i=0; while(i<t.length){ sum+=t[i]; i++; } av=(double)sum/10; System.out.println(av);
}
}
///////////
public class Ex4 {
/** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub
int t[]={67,66,87,65,98,97,65,55,69,59}; int sum=0; double av; int i=0; do{ sum+=t[i]; i++; }while(i<t.length); av=(double)sum/10; System.out.println(av);
For迴圈 public class ex1{ public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double a; for(int i=0; i<t.length; i++) sum+=t[i]; a=(double)sum/10; System.out.println(a); } } while迴圈
public class ex2 { public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double b; int i=0; while( i<t.length){ sum+=t[i]; i++; } b=(double)sum/10; System.out.println(b); } } do while迴圈
public class ex3 { public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double c; int i=0; do{ sum+=t[i]; i++; }while(i<t.length); c=(double)sum/10; System.out.println(c); } }
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; for(int i=0; i<t.length; i++) sum+=t[i]; av=(double)sum/10; System.out.println(av); }
}
public class ex2 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; while(i<t.length){ sum+=t[i]; i++; } av=(double)sum/10; System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; do{ sum+=t[i]; i++; }while(i<t.length); av=(double)sum/10; System.out.println(av);
public class fo { public static void main(String[] args){ int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; for(int i=0; i<t.length; i++) sum+=t[i];
av=(double)sum/10; System.out.print("for-pool,av="); System.out.println(av); int i=0; while(i<t.length){ sum+=t[i]; i++; } System.out.print("whlie-pool,av="); System.out.println(av); int a=0; do { sum+=t[a]; a++; }while(a<t.length); System.out.print("do whlie-pool,av="); System.out.println(av);
public class aa { public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; for(int i=0; i<t.length; i++) sum+=t[i]; av=(double)sum/10; System.out.println("for-loop:"+av);
int t1[]={453,68,6768,78,89,56,34,87,3456,77}; int sum1=0; double av1; int i=0; while(i<t1.length){ sum1+=t1[i]; i++; } av1=(double)sum1/10; System.out.println("while-loop:"+av1);
int t2[]={453,68,6768,78,89,56,34,87,3456,77}; int sum2=0; double av2; int i1=0; do{ sum2+=t2[i1]; i1++; }while(i1<t2.length); av2=(double)sum2/10; System.out.println("do-while-loop:"+av2); } }
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; for(int i=0; i<t.length; i++) sum+=t[i]; av=(double)sum/10; System.out.println(av); }
}
while迴圈
public class ex2 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; while(i<t.length){ sum+=t[i]; i++; } av=(double)sum/10; System.out.println(av);
}
}
do-while迴圈
public class ex3 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; do{ sum+=t[i]; i++; }while(i<t.length); av=(double)sum/10; System.out.println(av);
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; for(int i=0; i<t.length; i++) sum+=t[i]; av=(double)sum/10; System.out.println(av); }
}
while迴圈
public class ex2 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; while(i<t.length){ sum+=t[i]; i++; } av=(double)sum/10; System.out.println(av);
}
}
do-while迴圈
public class ex3 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; do{ sum+=t[i]; i++; }while(i<t.length); av=(double)sum/10; System.out.println(av);
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; for(int i=0; i<t.length; i++) sum+=t[i]; av=(double)sum/10; System.out.println(av); }
}
public class a02 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; while(i<t.length){ sum+=t[i]; i++; } av=(double)sum/10; System.out.println(av);
}
}
public class a03 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; do{ sum+=t[i]; i++; }while(i<t.length); av=(double)sum/10; System.out.println(av);
public class abc01 { public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; for(int i=0; i<t.length; i++) sum+=t[i]; av=(double)sum/10; System.out.println(av); }
}
public class abc02 { public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; while(i<t.length){ sum+=t[i]; i++; } av=(double)sum/10; System.out.println(av); }
}
public class abc03 { public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; do{ sum+=t[i]; i++; }while(i<t.length); av=(double)sum/10; System.out.println(av); }
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; for(int i=0; i<t.length; i++) sum+=t[i]; av=(double)sum/10; System.out.println(av); }
}
public class ex2 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; while(i<t.length){ sum+=t[i]; i++; } av=(double)sum/10; System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; do{ sum+=t[i]; i++; }while(i<t.length); av=(double)sum/10; System.out.println(av);
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; for(int i=0; i<t.length; i++) sum+=t[i]; av=(double)sum/10; System.out.println(av); }
}
public class ex2 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; while(i<t.length){ sum+=t[i]; i++; } av=(double)sum/10; System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; do{ sum+=t[i]; i++; }while(i<t.length); av=(double)sum/10; System.out.println(av);
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; for(int i=0; i<t.length; i++) sum+=t[i]; av=(double)sum/10; System.out.println(av); }
}
public class ex3 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; while(i<t.length){ sum+=t[i]; i++; } av=(double)sum/10; System.out.println(av);
}
}
public class ex4 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; do{ sum+=t[i]; i++; }while(i<t.length); av=(double)sum/10; System.out.println(av);
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; for(int i=0; i<t.length; i++) sum+=t[i]; av=(double)sum/10; System.out.println(av); } }
public class ex2 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; while(i<t.length){ sum+=t[i]; i++; } av=(double)sum/10; System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; do{ sum+=t[i]; i++; }while(i<t.length); av=(double)sum/10; System.out.println(av);
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; for(int i=0; i<t.length; i++) sum+=t[i]; av=(double)sum/10; System.out.println(av); }
}
public class ex2 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; while(i<t.length){ sum+=t[i]; i++; } av=(double)sum/10; System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; do{ sum+=t[i]; i++; }while(i<t.length); av=(double)sum/10; System.out.println(av);
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; for(int i=0; i<t.length; i++) sum+=t[i]; av=(double)sum/10; System.out.println(av); }
}
while迴圈
public class EX2 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; while(i<t.length){ sum+=t[i]; i++; } av=(double)sum/10; System.out.println(av);
}
}
do-while迴圈
public class ex3 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; do{ sum+=t[i]; i++; }while(i<t.length); av=(double)sum/10; System.out.println(av);
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; for(int i=0; i<t.length; i++) sum+=t[i]; av=(double)sum/10; System.out.println(av); }
}
public class ex2 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; while(i<t.length){ sum+=t[i]; i++; } av=(double)sum/10; System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; do{ sum+=t[i]; i++; }while(i<t.length); av=(double)sum/10; System.out.println(av);
public class pig { public static void main(String[] args){ int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; for(int i=0; i<t.length; i++) sum+=t[i];
av=(double)sum/10; System.out.print("for-pool,av="); System.out.println(av); int i=0; while(i<t.length){ sum+=t[i]; i++; } System.out.print("whlie-pool,av="); System.out.println(av); int a=0; do { sum+=t[a]; a++; }while(a<t.length); System.out.print("do whlie-pool,av="); System.out.println(av);
public class ex1{ public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double a; for(int i=0; i<t.length; i++) sum+=t[i]; a=(double)sum/10; System.out.println(a); } } while迴圈
public class ex2 { public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double b; int i=0; while( i<t.length){ sum+=t[i]; i++; } b=(double)sum/10; System.out.println(b); } } do while迴圈
public class ex3 { public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double c; int i=0; do{ sum+=t[i]; i++; }while(i<t.length); c=(double)sum/10; System.out.println(c); } }
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; for(int i=0; i<t.length; i++) sum+=t[i]; av=(double)sum/10; System.out.println(av); }
}
public class ex2 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; while(i<t.length){ sum+=t[i]; i++; } av=(double)sum/10; System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; do{ sum+=t[i]; i++; }while(i<t.length); av=(double)sum/10; System.out.println(av);
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; for(int i=0; i<t.length; i++) sum+=t[i]; av=(double)sum/10; System.out.println(av); }
}
public class ex2 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; while(i<t.length){ sum+=t[i]; i++; } av=(double)sum/10; System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; do{ sum+=t[i]; i++; }while(i<t.length); av=(double)sum/10; System.out.println(av);
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; for(int i=0; i<t.length; i++) sum+=t[i]; av=(double)sum/10; System.out.println(av); }
}
public class ex2 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; while(i<t.length){ sum+=t[i]; i++; } av=(double)sum/10; System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; do{ sum+=t[i]; i++; }while(i<t.length); av=(double)sum/10; System.out.println(av);
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; for(int i=0; i<t.length; i++) sum+=t[i]; av=(double)sum/10; System.out.println(av); }
}
public class ex2 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; while(i<t.length){ sum+=t[i]; i++; } av=(double)sum/10; System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) { int t[]={453,68,6768,78,89,56,34,87,3456,77}; int sum=0; double av; int i=0; do{ sum+=t[i]; i++; }while(i<t.length); av=(double)sum/10; System.out.println(av);
39 則留言:
// for
int t[]={453,68,6768,78,89,56,34,87,3456,77};
double sum = 0;
for (int i = 0; i < t.length; i += 1) {
sum = sum + t[i];
}
System.out.println(sum / t.length);
// while
int t[]={453,68,6768,78,89,56,34,87,3456,77};
double sum2 = 0;
int i = 0;
while (i < t.length) {
sum2 = sum2 + t[i];
i = i + 1;
}
System.out.println(sum2 / t.length);
// do-while
int t[]={453,68,6768,78,89,56,34,87,3456,77};
double sum3 = 0;
int i = 0;
do {
sum3 = sum3 + t[i];
i = i + 1;
} while (i < t.length);
System.out.println(sum3 / t.length);
public class CS {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println("for-loop:"+av);
int sum1=0;
double av1;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
System.out.println("while-loop:"+av);
int sum2=0;
double av2;
int i1=0;
do{
sum+=t[i1];
i++;
}while(i<t.length);
System.out.println(" do-while-loop:"+av);
}
}
public class Ex2 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int t[]={67,66,87,65,98,97,65,55,69,59};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
//////////
public class Ex3 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int t[]={67,66,87,65,98,97,65,55,69,59};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
///////////
public class Ex4 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int t[]={67,66,87,65,98,97,65,55,69,59};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class Ex2 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int t[]={67,66,87,65,98,97,65,55,69,59};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
//////////
public class Ex3 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int t[]={67,66,87,65,98,97,65,55,69,59};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
///////////
public class Ex4 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int t[]={67,66,87,65,98,97,65,55,69,59};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
For迴圈
public class ex1{
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double a;
for(int i=0; i<t.length; i++)
sum+=t[i];
a=(double)sum/10;
System.out.println(a);
}
}
while迴圈
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double b;
int i=0;
while( i<t.length){
sum+=t[i];
i++;
}
b=(double)sum/10;
System.out.println(b);
}
}
do while迴圈
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double c;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
c=(double)sum/10;
System.out.println(c);
}
}
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class fo {
public static void main(String[] args){
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.print("for-pool,av=");
System.out.println(av);
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
System.out.print("whlie-pool,av=");
System.out.println(av);
int a=0;
do
{
sum+=t[a];
a++;
}while(a<t.length);
System.out.print("do whlie-pool,av=");
System.out.println(av);
}
}
public class karama
{
public static void main(String[] args)
{
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.print("for-pool,av=");
System.out.println(av);
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
System.out.print("whlie-pool,av=");
System.out.println(av);
int a=0;
do
{
sum+=t[a];
a++;
}while(a<t.length);
System.out.print("do whlie-pool,av=");
System.out.println(av);
}
}
public class aa {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println("for-loop:"+av);
int t1[]={453,68,6768,78,89,56,34,87,3456,77};
int sum1=0;
double av1;
int i=0;
while(i<t1.length){
sum1+=t1[i];
i++;
}
av1=(double)sum1/10;
System.out.println("while-loop:"+av1);
int t2[]={453,68,6768,78,89,56,34,87,3456,77};
int sum2=0;
double av2;
int i1=0;
do{
sum2+=t2[i1];
i1++;
}while(i1<t2.length);
av2=(double)sum2/10;
System.out.println("do-while-loop:"+av2);
}
}
for迴圈
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
while迴圈
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
do-while迴圈
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
for迴圈
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
while迴圈
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
do-while迴圈
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class test {
public static void main(String[] args)
{
//////////////for///////////////////////////
int m=0;
double sum1=0,x=0;
double a[]={453,68,6768,78,89,56,34,87,3456,77};
for(int i=0;i<a.length;i++)
{
m++;
sum1+=a[i];
}
x=sum1/m;
System.out.print("for="+x);
///////////////////////////////////////
/////////////while/////////////////////
double sum2=0,av=0;
int x=0;
double a[]={453,68,6768,78,89,56,34,87,3456,77};
while(x<a.length)
{
sum2=sum2+a[x];
x++;
}
av=sum2/x;
System.out.print("while="+av);
///////////////////////////////////
/////////////do-while///////////////////
double sum3=0,av=0;
int x=0;
double a[]={453,68,6768,78,89,56,34,87,3456,77};
do{
sum3+=a[x];
x++;
}while(x<a.length);
av=sum3/x;
System.out.println("do-while="+av);
///////////////////////////////////
}
}
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class a01 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class a02 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class a03 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class abc01 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class abc02 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class abc03 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
int t[]={67,66,87,65,98,97,65,55,69,59};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
----------------------------------
public static void main(String[] args) {
// TODO Auto-generated method stub
int t[]={67,66,87,65,98,97,65,55,69,59};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
-------------------------------
ublic static void main(String[] args) {
// TODO Auto-generated method stub
int t[]={67,66,87,65,98,97,65,55,69,59};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex4 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
D9935206 張憶文
ex2
public static void main(String[] args) {
int t[]={87,50,87,65,69,92,65,40,69,30};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/8;
System.out.println(av);
_____________________________
ex3
public static void main(String[] args) {
int t[]={67,70,56,65,80,97,63,70,80,59};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/9;
System.out.println(av);
___________________________
ex4
public static void main(String[] args) {
int t[]={70,52,17,96,53,74,51,40,89,56};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
D9935206 張憶文
ex2
public static void main(String[] args) {
int t[]={87,50,87,65,69,92,65,40,69,30};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/8;
System.out.println("for-loop:"+av);
_____________________________
ex3
public static void main(String[] args) {
int t[]={67,70,56,65,80,97,63,70,80,59};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/9;
System.out.println(av);
___________________________
ex4
public static void main(String[] args) {
int t[]={70,52,17,96,53,74,51,40,89,56};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
public class paper {
public static void main(String[] args)
{
-----------------for
int m=0;
double sum1=0,x=0;
double a[]={453,68,6768,78,89,56,34,87,3456,77};
for(int i=0;i<a.length;i++)
{
m++;
sum1+=a[i];
}
x=sum1/m;
System.out.print("for="+x);
------------------------------------------------
-----------------while
double sum2=0,av=0;
int x=0;
double a[]={453,68,6768,78,89,56,34,87,3456,77};
while(x<a.length)
{
sum2=sum2+a[x];
x++;
}
av=sum2/x;
System.out.print("while="+av);
------------------------------------------------
-----------------do-while
double sum3=0,av=0;
int x=0;
double a[]={453,68,6768,78,89,56,34,87,3456,77};
do{
sum3+=a[x];
x++;
}while(x<a.length);
av=sum3/x;
System.out.println("do-while="+av);
------------------------------------------------
}
}
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class EX1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
while迴圈
public class EX2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
do-while迴圈
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class aaa {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class bbb {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ccc {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class AK1 {
public static void main(String[] args)
{
//////////////for///////////////////////////
int m=0;
double sum1=0,x=0;
double a[]={453,68,6768,78,89,56,34,87,3456,77};
for(int i=0;i<a.length;i++)
{
m++;
sum1+=a[i];
}
x=sum1/m;
System.out.print("for="+x);
///////////////////////////////////////
/////////////while/////////////////////
double sum2=0,av=0;
int x=0;
double a[]={453,68,6768,78,89,56,34,87,3456,77};
while(x<a.length)
{
sum2=sum2+a[x];
x++;
}
av=sum2/x;
System.out.print("while="+av);
///////////////////////////////////
/////////////do-while///////////////////
double sum3=0,av=0;
int x=0;
double a[]={453,68,6768,78,89,56,34,87,3456,77};
do{
sum3+=a[x];
x++;
}while(x<a.length);
av=sum3/x;
System.out.println("do-while="+av);
///////////////////////////////////
}
}
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class EX1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class pig {
public static void main(String[] args){
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.print("for-pool,av=");
System.out.println(av);
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
System.out.print("whlie-pool,av=");
System.out.println(av);
int a=0;
do
{
sum+=t[a];
a++;
}while(a<t.length);
System.out.print("do whlie-pool,av=");
System.out.println(av);
}
}
public class ex1{
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double a;
for(int i=0; i<t.length; i++)
sum+=t[i];
a=(double)sum/10;
System.out.println(a);
}
}
while迴圈
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double b;
int i=0;
while( i<t.length){
sum+=t[i];
i++;
}
b=(double)sum/10;
System.out.println(b);
}
}
do while迴圈
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double c;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
c=(double)sum/10;
System.out.println(c);
}
}
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class CS {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println("for-loop:"+av);
int sum1=0;
double av1;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
System.out.println("while-loop:"+av);
int sum2=0;
double av2;
int i1=0;
do{
sum+=t[i1];
i++;
}while(i<t.length);
System.out.println(" do-while-loop:"+av);
}
}
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class CS {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println("for-loop:"+av);
int sum1=0;
double av1;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
System.out.println("while-loop:"+av);
int sum2=0;
double av2;
int i1=0;
do{
sum+=t[i1];
i++;
}while(i<t.length);
System.out.println(" do-while-loop:"+av);
}
}
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
張貼留言