-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava023_if.java
More file actions
32 lines (28 loc) · 854 Bytes
/
Copy pathJava023_if.java
File metadata and controls
32 lines (28 loc) · 854 Bytes
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
package java0822_statement;
/*
* 각 월의 마지막 일
* 1 3 5 7 8 10 12 => 31
* 4 6 9 11 => 30
* 2 => 28
*
* [출력결과]
* 4월의 마지막 일은 30입니다.
*/
public class Java023_if {
public static void main(String[] args) {
int month = 4; // 월
int lastDay = -1; // 마지막 일
////////////////////////////////////////////////////////
if (month == 2) {
lastDay = 28;
} else if (month == 4 || month == 6 || month == 9 || month == 11) {
lastDay = 30;
} else if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
lastDay = 31;
} else {
System.out.println("비정상적인 입력입니다.");
}
////////////////////////////////////////////////////////
System.out.printf("%d월의 마지막 일은 %d일 입니다.", month, lastDay);
}
}