package chapter20230808;
import java.util.*;
public class test07 {
public static void main(String[] args) {
boolean run = true;
int studentNum = 0;
int[] scores = null;
int max = 0;
int average = 0;
Scanner scanner = new Scanner(System.in);
while (run) {
System.out.println("-----------------------------------------------------");
System.out.println("1.학생수 | 2.점수입력 | 3.점수리스트 | 4.분석 | 5.종료");
System.out.println("-----------------------------------------------------");
System.out.print("선택> ");
int selectNo = scanner.nextInt();
if (selectNo == 1) {
System.out.print("학생수> ");
studentNum = scanner.nextInt();
scores = new int [studentNum];
System.out.println(Arrays.toString(scores));
} else if (selectNo == 2) {
for(int i = 0; i < scores.length; i++) {
System.out.print("각 학생 점수> ");
scores[i] = scanner.nextInt();
}
System.out.println(Arrays.toString(scores));
} else if (selectNo == 3) {
for(int i = 0; i < scores.length; i++) {
System.out.println("학생" +"["+ i +"] "+ scores[i]);
}
} else if (selectNo == 4) {
for(int i = 0; i < scores.length; i++) {
max = scores[i] > max ? scores[i] : max;
average += scores[i];
}
System.out.println("최고 점수는 " + max + " 이며" + " 평균 점수는 " + (double)average/studentNum + " 입니다.");
} else if (selectNo == 5) {
run = false;
}
}
System.out.println("프로그램 종료");
}
}