-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMission1.java
More file actions
45 lines (40 loc) · 1.12 KB
/
Mission1.java
File metadata and controls
45 lines (40 loc) · 1.12 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
package chapter3;
import java.util.Scanner;
public class Mission1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
int kor, eng, math;
System.out.print("국어 점수: ");
kor = sc.nextInt();
if (kor < 0 || kor > 100) {
sc.close();
System.out.println("잘못된 점수, 프로그램을 종료합니다.");
break;
}
System.out.print("영어 점수: ");
eng = sc.nextInt();
if (eng < 0 || eng > 100) {
sc.close();
System.out.println("잘못된 점수, 프로그램을 종료합니다.");
break;
}
System.out.print("수학 점수: ");
math = sc.nextInt();
if (math < 0 || math > 100) {
sc.close();
System.out.println("잘못된 점수, 프로그램을 종료합니다.");
break;
}
int sum = kor + eng + math;
System.out.println("총계: " + sum);
System.out.println("평균: " + Math.round(sum / 3.0 * 100) / 100.0);
if (kor < 60 || eng < 60 || math < 60) {
System.out.println("과락");
} else {
System.out.println(sum >= 210 ? "통과" : "불통");
}
System.out.println();
}
}
}