// 한 사람의 성적처리 프로그램
// 입력 : 이름, 국어, 영어, 수학
// 연산 : 총점, 평균
// 출력 : 이름, 국어, 영어, 수학, 총점, 평균
public static void main(String[] args) {
String name; // 이름
int[] score; // kor,eng,mat,total
float avg = 0;
String[] Subject_name = { "국어", "영어", "수학", "총점" };
score = new int[Subject_name.length];
Scanner sc = new Scanner(System.in);
// 입력
System.out.print("이름을 입력하시오 : ");
name = sc.nextLine();
for (int i = 0; i < score.length - 1; i++) {
System.out.print(Subject_name[i] + "점수를 입력하시오 : ");
score[i] = sc.nextInt();
score[score.length - 1] += score[i];
}
avg = score[score.length - 1] / (score.length - 1);
// 출력
System.out.print("이름 : " + name);
for (int i = 0; i < score.length; i++) {
if (i == score.length - 1) {
System.out.print(", " + Subject_name[i] + " : " + score[i]);
break;
}
System.out.print(", " + Subject_name[i] + " : " + score[i]);
}
System.out.print(", 평균 : " + avg);
}