-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayEx8.java
More file actions
37 lines (31 loc) · 1.24 KB
/
Copy pathArrayEx8.java
File metadata and controls
37 lines (31 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package array.ex;
import java.util.Scanner;
public class ArrayEx8 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("학생의 수를 입력하세요 : ");
int student = scanner.nextInt();
int[][] score = new int[student][3];
int[] total = new int[4];
String[] subjects = {"국어", "영어", "수학"};
for (int i = 0 ; i < score.length; i++) {
System.out.println((i+1) + "번 학생의 성적을 입력하세요");
for (int j = 0; j < 3; j++) {
System.out.print(subjects[j] + "점수 : ");
score[i][j] = scanner.nextInt();
}
System.out.println();
}
for(int i = 0; i < score.length; i++) {
System.out.println((i+1) + "번 학생 점수");
for (int j = 0; j < 3; j++) {
System.out.print(subjects[j] + "점수 : " + score[i][j] + " ");
total[i] += score[i][j];
}
System.out.println();
System.out.print("총점 : " + total[i] + " 평균 : " + (double)total[i] / subjects.length);
System.out.println();
System.out.println();
}
}
}