-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray_Quiz_03.java
More file actions
54 lines (37 loc) · 1.43 KB
/
array_Quiz_03.java
File metadata and controls
54 lines (37 loc) · 1.43 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package study;
import java.util.Scanner;
public class array_Quiz_03 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String[] name = { "잭", "김","총점","과평" };
String[] subject = { "국어", "영어", "수리", "과탐","합계","개인평균" };
double[][] score = new double[name.length][subject.length];
for (int i = 0; i < name.length-2; i++) {
for (int j = 0; j < subject.length-2; j++) {
System.out.print(name[i] + "의 ");
System.out.print(subject[j] + "점수 >>>>");
score[i][j] = sc.nextDouble();
score[i][subject.length-2]+= score[i][j]; // 합계
double sum = (double)(score[i][subject.length-2]);
score[name.length-2][j] += score[i][j]; // 총점
double chung = score[name.length-2][j];
score[name.length-2][subject.length-2] += score[i][j]; // 전체합계
score[i][subject.length-1] += (double)(sum/(subject.length-2)); // 개인평균
score[name.length-1][j] += (double)(chung/(name.length-2)); // 개인평균
}
}
System.out.println("성적 결과");
System.out.print("\t");
for (int j = 0; j < subject.length; j++) {
System.out.print(subject[j] + "\t");
}
System.out.println();
for (int i = 0; i < name.length; i++) {
System.out.print(name[i] + "\t");
for (int j = 0; j < subject.length; j++) {
System.out.print(score[i][j] + "\t");
}
System.out.println();
}
}
}