-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProb01.java
More file actions
68 lines (60 loc) · 1.42 KB
/
Copy pathProb01.java
File metadata and controls
68 lines (60 loc) · 1.42 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
package java0822_statement.prob;
/*
* switch~case문을 이용해서 년도에 해당하는 띠를 구하는 프로그램을 구현하시오.
* 1. 12가지 띠
* 원숭이, 닭, 개, 돼지, 쥐, 소, 호랑이, 토끼, 용, 뱀, 말, 양
* 2 띠구하는 공식
* year%12의 결과가
* 0이면 "원숭이", 1이면 "닭" 2이면 "개", 3이면 "돼지",
* 4이면 "쥐", 5이면 "소", 6이면 "호랑이", 7이면 "토끼",
* 8이면 "용", 9이면 "뱀", 10이면 "말", 11이면 "양"
*
* 3 출력결과
* 2012년도의 태생은 용띠입니다.
*/
public class Prob01 {
public static void main(String[] args) {
int year = 2012;
String animal = "";
// 여기에서 구현하세요////////////////////////////////
switch (year % 12) {
case 0:
animal = "원숭이";
break;
case 1:
animal = "닭";
break;
case 2:
animal = "개";
break;
case 3:
animal = "돼지";
break;
case 4:
animal = "쥐";
break;
case 5:
animal = "소";
break;
case 6:
animal = "호랑이";
break;
case 7:
animal = "토끼";
break;
case 8:
animal = "용";
break;
case 9:
animal = "뱀";
break;
case 10:
animal = "말";
break;
case 11:
animal = "양";
}
///////////////////////////////////////////////
System.out.println(year + "년도의 태생은 " + animal + "띠입니다.");
}// end main()
}// end class