Loading...
Loading...
Loading...
A college app greets students when they open it. Read the hour of the day in 24-hour time and print the greeting:
Good morningGood afternoonGood eveningGood nightExample 1
Input
9
Output
Good morning
9 is between 5 and 11.
Example 2
Input
18
Output
Good evening
18 is between 17 and 20.
Example 3
Input
2
Output
Good night
Early hours count as night.
Try the problem first. Open one hint at a time.
The night hours sit at both ends of the day, so leave them for the final else.
In a ladder, each later test already knows the earlier ones failed, but here the first range has a lower end too: test hour >= 5 && hour <= 11.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor