점수 평균, 총합계, 최고점, 최소점
public class ArrayTest {
public static void main(String[] args) {
String name[] = new String[] { "임꺽정", "강감찬", "이순신", "율곡", "신사임당" };
int score[] = { 90, 95, 100, 85, 20 };
int total = 0;
float avg = 0f;
int MAX = score[1];
int MIN = score[1];
for (int i = 0; i < score.length; i++) {
System.out.println(name[i] + "의 점수는 : " + score[i]);
if(score[i]>MAX){
MAX = score[i];
}
if(score[i]<MIN){
MIN = score[i];
}
total += score[i];
avg = total / name.length;
}
System.out.println("=====================");
System.out.println("총 점수는 : " + total);
System.out.println("총 평균은 : " + avg);
System.out.println("최고점은 : " + MAX);
System.out.println("최소점은 : " + MIN);
System.out.println("=====================");
}
}