-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProb003_Calendar.java
More file actions
40 lines (35 loc) · 988 Bytes
/
Copy pathProb003_Calendar.java
File metadata and controls
40 lines (35 loc) · 988 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
33
34
35
36
37
38
39
40
package java0907_api.answ;
import java.util.Calendar;
/*
* [출력결과]
* <4시부터 12시 미만일때>
* 지금은 5시 35분입니다.
* Good Morning
*
* <12시부터 18시 미만일때>
* 지금은 16시 49분입니다.
* Good Afternoon
*
* <18시부터 22시 미만일때>
* 지금은 20시 30분입니다.
* Good Evening
*
* <그외 일때>
* Good Night
*/
public class Prob003_Calendar {
public static void main(String[] args) {
Calendar now = Calendar.getInstance();
int hourOfDay = now.get(Calendar.HOUR_OF_DAY);
int minute = now.get(Calendar.MINUTE);
System.out.println("지금은 " + hourOfDay + "시 " + minute + "분입니다.");
if(hourOfDay >= 4 && hourOfDay < 12)
System.out.println("Good Morning");
else if(hourOfDay >= 12 && hourOfDay < 18)
System.out.println("Good Afternoon");
else if(hourOfDay >= 18 && hourOfDay < 22)
System.out.println("Good Evening");
else
System.out.println("Good Night");
}
}