herrDeng網內搜尋

自訂搜尋

Ads

2014年9月17日 星期三

改寫成for迴圈

public class for1 {
 public static void main(String[] args) {
  int [] a={23,67,89,54};
  int sum=0;
  double av;
  int i=0;
  do{
   sum+=a[i++];
  }
  while( i<=a.length) ;
  av=(double)sum/a.length;
  System.out.println(av);
 }
}

29 則留言:

B10233082唐偉強 提到...

public class day917 {
public static void main(String[] args) {
int [] a={23,67,89,54};
int sum=0;
double av;
for(int i=0;i<a.length;i++){
sum+=a[i];
}
av=(double)sum/a.length;
System.out.println(av);

}
}

B10233069連于傑 提到...

public class for1 {
public static void main(String[] args) {
int [] a={23,67,89,54};
int sum=0;
double av;
for (int i=0;i<x.length;i++)
sum+=x[i];
System.out.println();
}
}

b10233072黃君寰 提到...


public class oo1 {

public static void main(String[] args) {
int [] x={111,222,333,444,555};
int sum=0;
for(int i=0; i<x.length; i++)
sum+=x[i];
System.out.println(sum);


}

}

b10211216洪資恒 提到...

package hello1;

public class hello1 {

public static void main(String[] args) {
int [] x={32,49,50,68,93};
int sum=0;
for(int i=0; i<x.length; i++)
sum+=x[i];
System.out.println(sum);

}

}

B10233080陳芊慈 提到...


public class DLAM {

public static void main(String[] args) {
int [] x={20,30,40,50,60};
int sum=0;
for(int i=0; i<x.length; i++)
sum+=x[i];
System.out.println(sum);

}

}

B10233070劉思涵 提到...


public class HHE1 {

public static void main(String[] args) {
int [] x={19,28,34,42,53};
int sum=0;
for(int i=0; i<x.length; i++)
sum+=x[i];
System.out.println(sum);

}

}

B10233067江珮璇 提到...

public class ex {
public static void main(String[] args) {
int []a={23,67,89,54};
int sum=0;
double av;
for(int i=0;i<=a.length ;i++);
sum+=a[i];
av=(double)sum/a.length;
System.out.println(av);
}
}

B10233089錢玟薏 提到...

package hello;
public class ex {
public static void main(String[] args) {
int [] a={23,67,89,54};
int sum=0;
double av;
for(int i=0; i<=a.length;i++) {
sum += a[i];
av=(double)sum/a.length;
System.out.println(sum);
}
}
}

B10033116 陳柏諺 提到...

package b10033116_01;

public class Ex09 {
public static void main(String[] args) {
int[] a = { 23, 67, 89, 54 };
int sum = 0;
double av;
int i = 0;
// do {
for (i = 0; i &lt a.length; i++) {
sum += a[i++];
// } while (i &lt= a.length);
av = (double) sum / a.length;
System.out.println(av);
}
}
}

Unknown 提到...

B10233178


package homework;

public class array {
public static void main(String args[]){
int [] a={23,67,89,54};
int sum=0;
for(int i=0;i<a.length;i++){
sum+=a[i];
}
System.out.println(sum);
}

}

B10233110徐上竣 提到...

package hello;
public class Java123 {
public static void main(String[] args) {
int [] a={23,67,89,54};
int sum=0;
double av;
for(int i=0; i<=a.length;i++) {
sum += a[i];
av=(double)sum/a.length;
System.out.println(sum);
}
}
}

B10133186 蘇紘立 提到...

public class for1 {
public static void main(String[] args) {
int [] a={23,67,89,54};
int sum=0;
for(int i=0; i<x.length; i++)
sum+=x[i];
System.out.println(sum);


}
}

B10233097 邱宥甄 提到...



public class ONE {

public static void main(String[] args) {
int [] a={23,67,89,54};
int sum=0;
double av;
for (int i=0;i<a.length;i++)sum+=a[i];
av=(double)sum/a.length;
System.out.println(av);
}
}

Y10211027張君弘 提到...

public class text1 {
public static void main(String[] args) {
int [] a={23,67,89,54};
int sum=0;
double av;
for(int i=0; i<a.length;i++){
sum+=a[i];
}
av=(double)sum/a.length;
System.out.println(av);
}
}

B10233090 林清隆 提到...

public class ex1 {
public static void main(String[] args) {
int [] a={23,67,89,54};
int sum=0;
double av;
for(int i=0; i<a.length;i++){
sum+=a[i];
}
av=(double)sum/a.length;
System.out.println(av);
}
}

B10233084 陳億如 提到...

public class TTT {

public static void main(String[] args) {
int [] a={23,67,89,54};
int sum=0;
double av;
for (int i=0;i<a.length;i++)sum+=a[i];
av=(double)sum/a.length;
System.out.println(av);
}
}

B10233064莊英霆 提到...

package hello;
public class ex {
public static void main(String[] args) {
int [] a={88,68,58,08};
int sum=0;
double av;
for(int i=0; i<=a.length;i++) {
sum += a[i];
av=(double)sum/a.length;
System.out.println(sum);
}
}
}

B10233062 提到...

B10233069連于傑 提到...
public class for1 {
public static void main(String[] args) {
int [] a={10,20,30,40};
int sum=0;
double av;
for (int i=0;i<x.length;i++)
sum+=x[i];
System.out.println();
}
}

B10233087 黃少洋 提到...

public class hello {

public static void main(String[] args) {
int [] x={20,30,40,50,60};
int sum=0;
for(int i=0; i<x.length; i++)
sum+=x[i];
System.out.println(sum);

}

}

B10233063 張宜禎 提到...

public class hello {

public static void main(String[] args) {
int [] x={20,30,40,50,60};
int sum=0;
for(int i=0; i<x.length; i++)
sum+=x[i];
System.out.println(sum);

}

}

B10233075 謝如華 提到...

public class ex1 {

public static void main(String[] args) {
int [] x={20,30,40,50,60};
int sum=0;
for(int i=0; i<x.length; i++)
sum+=x[i];
System.out.println(sum);

}

}

B10233081 藍立凱 提到...

public class ex2 {

public static void main(String[] args) {
int [] x={20,30,40,50,60};
int sum=0;
for(int i=0; i<x.length; i++)
sum+=x[i];
System.out.println(sum);

}

}

B10233174 廖庭 提到...

public class 165 {

public static void main(String[] args) {
int [] x={20,30,40,50,60};
int sum=0;
for(int i=0; i<x.length; i++)
sum+=x[i];
System.out.println(sum);

}

}

B10233095李元宏 提到...


public class homework02 {


public static void main(String[] args) {

int [] a={23,67,89,54};
int sum=0;
double av;
for(int i=0;i<a.length;i++){
sum+=a[i];
}
av=(double)sum/a.length;
System.out.println(av);
}
}

b10233068邱佳函 提到...

public class ex2{

public static void main(String[] args) {
int [] x={2,30,40,50,60};
int sum=0;
for(int i=0; i<x.length; i++)
sum+=x[i];
System.out.println(sum);
}
}

B10233092許凡耕 提到...

package hello;
public class ex {
public static void main(String[] args) {
int [] a={40,59,78,87};
int sum=0;
double av;
for(int i=0; i<=a.length;i++) {
sum += a[i];
av=(double)sum/a.length;
System.out.println(sum);
}
}
}

B10233103蔡登曜 提到...

public class z01 {

public static void main(String[] args) {
int [] x={10,20,30,40,50};
int sum=0;
for(int i=0; i<x.length; i++)
sum+=x[i];
System.out.println(sum);

}

}

黃聖評 B10233062 提到...

public class day1009 {
public static void main(String[] args) {
int [] a={55,25,75,94};
int sum=0;
double av;
for(int i=0;i<a.length;i++){
sum+=a[i];
}
av=(double)sum/a.length;
System.out.println(av);

}
}

B10033024 沈旻翰 提到...

public class day917 {
public static void main(String[] args) {
int [] a={23,67,89,54};
int sum=0;
double av;
for(int i=0;i<a.length;i++){
sum+=a[i];
}
av=(double)sum/a.length;
System.out.println(av);

}
}

Related Posts Plugin for WordPress, Blogger...

熱門文章