-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalStudentScore.java
More file actions
62 lines (50 loc) · 1.77 KB
/
Copy pathCalStudentScore.java
File metadata and controls
62 lines (50 loc) · 1.77 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
55
56
57
58
59
60
61
62
import java.util.Scanner;
public class CalStudentScore {
public static void main(String[] args) {
boolean run = true;
int studentNum = 0;
int[] scores = null;
Scanner scanner = new Scanner(System.in);
while(run) {
System.out.println("------------------------------------------------------------------");
System.out.println("1. 학생수 | 2. 점수입력 | 3. 점수리스트 | 4. 분석 | 5. 종료");
System.out.println("------------------------------------------------------------------");
System.out.println("선택 > \r\n");
int selectNo = scanner.nextInt();
if (selectNo == 1) {System.out.println("학생수>\r\n");
studentNum = scanner.nextInt();
System.out.println("학생수 : " + String.valueOf(studentNum));
scores = new int[studentNum];
} else if (selectNo == 2) {
for (int i = 0; i < scores.length; i++) {
System.out.println("scores[" + String.valueOf(i) + "]\r\n");
scores[i] = scanner.nextInt();
}
System.out.println("점수 입력 완료");
} else if (selectNo == 3) {
System.out.println(scores.length);
for (int i = 0; i < scores.length; i++) {
System.out.println("scores[" + String.valueOf(i) + "]" + String.valueOf(scores[i]));
}
System.out.println("점수리스트 출력완료");
} else if (selectNo == 4) {
int max = 0;
int total = 0;
int avg = 0;
for (int i = 0; i < scores.length; i++) {
if (max < scores[i]) {
max = scores[i];
total = total + scores[i];
}
}
avg = total / scores.length;
System.out.println("최고점수 : " + max);
System.out.println("평균 : " + avg);
} else if (selectNo == 5) {
run = false;
System.out.println("종료합니다.");
}
}
scanner.close();
}
}