due at midnight on +60
This assignment will help you practice using nested conditional and switch statements. Call your program p5time.cpp
and submit to this dropbox for project 5.
Write a program that will:
03:08
rather than 3:8
for 3:08 AM
.Again, to receive full credit:
Here are some sample runs of my solution, but it should work for other numbers as well.
Enter hour (0-23): 11
Enter minute (0-59): 15
11:15 is 11:15 AM
quarter past eleven in the morning
Enter hour (0-23): 17
Enter minute (0-59): 58
17:58 is 5:58 PM
six in the evening
Enter hour (0-23): 13
Enter minute (0-59): 21
13:21 is 1:21 PM
quarter past one in the afternoon
Enter hour (0-23): 13
Enter minute (0-59): 28
13:28 is 1:28 PM
half past one in the afternoon
Times around 45 minutes past the hour should, in English, refer to the subsequent hour:
Enter hour (0-23): 19
Enter minute (0-59): 48
19:48 is 7:48 PM
quarter til eight in the evening
When the hour is 12 or 0, it should refer to noon or midnight:
Enter hour (0-23): 12
Enter minute (0-59): 3
12:03 is 12:03 PM
noon
Enter hour (0-23): 0
Enter minute (0-59): 20
00:20 is 12:20 AM
quarter past midnight
But watch out when it’s close to 45 minutes after noon or midnight:
Enter hour (0-23): 12
Enter minute (0-59): 40
12:40 is 12:40 PM
quarter til one in the afternoon
Enter hour (0-23): 0
Enter minute (0-59): 40
00:40 is 12:40 AM
quarter til one in the morning
And don’t forget the error-checking:
Enter hour (0-23): -5
Error: hour out of range.
Enter hour (0-23): 24
Error: hour out of range.
Enter hour (0-23): 5
Enter minute (0-59): 70
Error: minute out of range.