Hello,
Im Really lost on a project im playing around with, could you provide me with a good set of code to use?
Here is a list of things it has to have.
• 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).
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.
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
Correct Out put
Start Time: 03:30pm End Time: 06:30pm Enterval Lenght: 03:00
|
I was playing around with the calculation and ran into a lot of issues.
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
|
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double x= 3;
double y= 30;
double z= (x * (3600)+ y * (60)) ;
double i= 6;
double j= 30;
double l= (i * (3600)+ j * (60)) ;
cout << left << setw(10) << "Start Time: "<< z
<< right << setw(20) << "End Time: "<< l
<< right << setw(30) <<"Enterval Lenght: "<< (z - l)/ 3600
<< endl;
}
|