-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSwitch.java
More file actions
75 lines (71 loc) · 1.56 KB
/
Switch.java
File metadata and controls
75 lines (71 loc) · 1.56 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
63
64
65
66
67
68
69
70
71
72
73
74
public class Switch {
public static void main(String[] args) {
/*
if (condition) {
do
} else if (condition2) {
do2
} else {
do3
}
switch (variable or operation) {
case condition1:
do1
break
case condition2:
do2
break
default:
defaultDo
}
*/
int score = 97;
String grade;
switch (score / 10) {
case 10:
grade = "A+";
break;
case 9:
grade = "A";
break;
case 8:
grade = "B";
System.out.println("참 잘했어요!");
break;
case 7:
grade = "C";
break;
case 6:
grade = "D";
break;
default:
grade = "F";
break;
}
System.out.println(grade);
int number = 134354;
// System.out.println(number%7);
switch (number%7) {
case 1:
System.out.print("One");
break;
case 2:
System.out.print("Two");
break;
case 3:
System.out.print("Three");
break;
case 4:
System.out.print("Four");
break;
case 5:
System.out.print("Five");
break;
case 6:
System.out.print("Six");
break;
default: // 반드시 default값 설정
break;
}
}
}