package ch05.sec12;
import java.util.Scanner;
public class Exam09 {
public static void main(String[] args) {
int [] students = null;
boolean run=true;
Scanner sca=new Scanner(System.in);
while(run) {
System.out.println("----------------------------------------------------");
System.out.println(" 1. 학생수 | 2.점수입력 | 3.점수리스트 | 4.분석 | 5.종료");
System.out.println("----------------------------------------------------");
System.out.print("선택> ");
String strNum1=sca.nextLine();
int num=Integer.parseInt(strNum1);
switch (num) {
case 1:
System.out.print("학생 수를 입력 : ");
String strNum2=sca.nextLine();
int i=Integer.parseInt(strNum2);
students=new int[i];
break;
case 2:
for(int j=0;j<students.length;j++) {
System.out.print("점수를 입력 (학생"+(j+1)+"번) : ");
String strNum3=sca.nextLine();
int score=Integer.parseInt(strNum3);
students[j]=score;
}
break;
case 3:
for(int k=0;k<students.length;k++) {
System.out.println("학생"+(k+1)+"번 점수 : "+students[k]);
}
break;
case 4:
int max=0;
for(int l=0;l<students.length;l++) {
if(max<students[l]) {
max=students[l];
}
}
System.out.println("높은 점수: "+max);
int sum=0;
for(int m=0;m<students.length;m++) {
sum += students[m];
}
System.out.println("총 학생 평균 :"+((double)sum/students.length));
break;
case 5:
run=false;
System.out.print("프로그램 종료");
break;
}
}
sca.close();
}
}