The 24-hour clock (often called military time) is a method of time keeping that numbers the hours in a day beginning at 00:00 (12:00am midnight)
The 24-hour clock (often called military time) is a method of time keeping that numbers the hours in a day beginning at 00:00 (12:00am midnight) through 23:59 (11:59pm). The standard format for a time is hh:mm.
The 12-hour clock is a method of time keeping that divides the day into two twelve hour periods,12:00am (midnight) to11:59am and 12:00pm (noon) to 11:59pm.
Design a C++ program that will use functions to accomplish the following
read each data set from the file (via Linux redirection, no prompts) - see description of data file below
display start time, end time, and length of interval between labelled and in the specified format - see output requirements below
continue processing data sets until the end of file is encountered
Data File
The data file for the program will consist of several sets of data. The first piece of data in each set will be an integer (12 or 24) that indicates whether the start and end times for an interval will be expressed using the 12-hour clock or the 24-hour clock.
If the first piece of data is a 12, then it will be followed by 2 times given in the 12-hour clock form. The first time will mark the start of the time interval and the second time will mark the end. Each time will be in the form: h:mm or hh:mm. Each time will be followed by an upper or lowercase 'a' or 'p' to complete the time. All times will be valid.
Sample data sets: 12 4:05P 07:35p 12 10:45A 3:17p
If the first piece of data is a 24, then it will be followed by 2 times given in the 24-hour clock form that indicate the start and end of a time interval. Each time will be in the form: h:mm or hh:mm. All times will be valid.
Sample data sets: 24 16:05 19:35 24 10:45 15:17
Output Requirements
For each data set in the file, display the start and end times followed by the length of the defined interval with appropriate labels.
All times must be displayed in the form: hh:mm (leading zeroes must be output). For example, an input time of 4:05 must be displayed as 04:05.
If the times are given using the 12-hour clock, each time must be followed by "am" or "pm" (whichever is appropriate). For example, an input time of 6:01 P must be displayed as 06:01pm.
Times must be displayed in the commonly accepted form (minutes will be between 00 and 59).
Length of time interval must be displayed in the form: hh:mm (leading zeroes must be output). For example 1 hour 7 minutes must be displayed as 01:07.
Assumptions
No error checking is necessary. All data in the input file will be as described.
For 12-hour clock times, the letter that designates whether the time is before or after noon can be either upper or lowercase (A, a, P, or p).
There will be 1 or more blanks between the clock type (12 or 24) and the start time. There will be 1 or more blanks between the start time and the end time.
There will be 0 or more blanks between the minutes and the before or after noon letter in a 12-hour time. For example, 5:15p 10:07 A
The start time will always be less than (precede) or equal to the end time. (Maximum time interval is 23:59).
Other Requirements
Declare all variables inside functions. Only named constants should be declared at the global level.
Pass parameters to communicate values between functions.
Program MUST implement at least 2 meaningful functions (in addition to main).
Never use goto statements in a program.
Sample terminal session: [joj5@bobby 17FA] $ more data4three 12 8:28 a 11:35A 24 5:30 14:52 24 00:00 23:59 12 06:05A 4:01 p [joj5@bobby 17FA] $ [joj5@bobby 17FA]$ make assign03 assign03.cpp -o assign03 [joj5@bobby 17FA]$ ./assign03 < data4three Juyeon Jo Lec Sec# 1019, Lab Sec# 1021, g++ Start time: 08:28am Start time: 05:30 Start time: 00:00 Start time: 06:05am [joj5@bobby 17FA] $ [joj5@bobby 17FA] $ End time: 11:35am End time: 14:52 End time: 23:59 End time: 04:01pm Assignment #3 Interval length: 03:07 Interval length: 09:22 Interval length: 23:59 Interval length: 09:56
Step by Step Solution
3.50 Rating (150 Votes )
There are 3 Steps involved in it
Step: 1
include include include include using namespace std const int MINUTESPERHOUR 60 const int HOURSPERDAY 24 const int MINUTESPERDAY HOURSPERDAY MINUTESPE...See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started