-
[JAVA] CodingTest 문제 1번 - ex1카테고리 없음 2022. 11. 8. 17:25
CodingTest 문제 1번 - ex1
public class studentScore {
public static void main(String[] args) {
int[][] student = { { 1, 2, 5, 10, 20 }, { 1, 41, 50, 60, 70 }, { 35, 45, 55, 60, 70 }, { 1, 20, 30, 49, 57 } };
int total = 0;
int count = 0;
int a = 0;
for (int i = 0; i < student.length; i++) {
for (int j = 0; j < student[i].length; j++) {
count++;
total += student[i][j];
a = total / count;
}
}
System.out.println("전체 합 :" + total);
System.out.println("평균 값 :" + a);
System.out.println("=============================");
for (int i = 0; i < student.length; i++) {
for (int j = 0; j < student[i].length; j++) {
if (student[i][j] > a) {
System.out.println(student[i][j] + "는 평균 이상입니다.");
}
}
}
}
}