C.E/Java
average예제
숨[Breath]
2013. 10. 19. 10:08
import java.lang.reflect.Array;
import java.util.Arrays;
public class Test {
public static void main(String[] args) {
int s[]={81,53,89,91,68};
int t[]={82,85,95,35,75};
int u[]={88,95,35,67,84};
int sum=0;
for(int i=0; i<=4; i++)
sum = sum+s[i];
// System.out.println(sum/5.0);
System.out.println(average(s));
System.out.println(average(t));
System.out.println(average(u));
// System.out.println(Arrays.toString(u));
}
private static double average(int sum[]) {
double all = 0;
for(int i=0; i<sum.length; i++)
all += sum[i];
all= all / sum.length;
return all;
}
}