public class Test2 {
public static void main(String[] args) {
int[][] mathScores = new int[2][3];
mathScores[0][0] = 80;
mathScores[0][1] = 70;
mathScores[0][2] = 62;
mathScores[1][0] = 81;
mathScores[1][1] = 100;
mathScores[1][2] = 78;
for (int i = 0; i < mathScores.length; i++) {
for (int k = 0; k < mathScores[i].length; k++) {
System.out.println("mathScores[" + i + "][" + k + "]:" + mathScores[i][k]);
}
}
System.out.println();
int totalStudent = 0;
int totalMathSum = 0;
for (int i = 0; i < mathScores.length; i++) {
totalStudent += mathScores[i].length;
for (int k = 0; k < mathScores[i].length; k++) {
totalMathSum += mathScores[i][k];
}
}
double totalMathAvg = (double) totalMathSum / totalStudent;
System.out.println("전체 학생의 수학 평균 점수:" + totalMathAvg);
System.out.println();
int[][] englishScores = new int[2][];
englishScores[0] = new int[2];
englishScores[1] = new int[3];
englishScores[0][0] = 90;
englishScores[0][1] = 91;
englishScores[1][0] = 92;
englishScores[1][1] = 93;
englishScores[1][2] = 94;
for (int i = 0; i < englishScores.length; i++) {
for (int k = 0; k < englishScores[i].length; k++) {
System.out.println("englishScores[" + i + "][" + k + "]:" + englishScores[i][k]);
}
}
System.out.println();
totalStudent = 0;
int totalEnglishSum = 0;
for (int i = 0; i < englishScores.length; i++) {
totalStudent += englishScores[i].length;
for (int k = 0; k < englishScores[i].length; k++) {
totalEnglishSum += englishScores[i][k];
}
}
double totalEnglishAvg = (double) totalEnglishSum / totalStudent;
System.out.println("전체 학생의 영어 평균 점수:" + totalEnglishAvg);
}
}
'JAVA 수업 > java 수업 기록' 카테고리의 다른 글
인터페이스의 세계로~~ (2) | 2023.06.05 |
---|---|
0602 수업 내용 (0) | 2023.06.02 |
0601 수업 내용 (0) | 2023.06.01 |
0531 수업 내용 (0) | 2023.05.31 |
0530 수업 내용 (0) | 2023.05.30 |