Starting from:

$15

Write an application to produce the following output in C++

Write an application to produce the following output in C++ 

Note: User is presented with a menu of three items: change time A, change time B, or exit. Once the user inputs time A (or B) the program shows the time A plus duration B, and the time difference between A and B.

=======================

Time A: 23:15 or 11:15 PM [1395]
Time B: 01:00 or 01:00 AM [60]
added: 00:15 duration: 22:15

[A] [B] [X] a
A: 4:30
Time A: 04:30 or 04:30 AM [270]
Time B: 01:00 or 01:00 AM [60]
added: 05:30 duration: 03:30

[A] [B] [X] b
B: 17:30
Time A: 04:30 or 04:30 AM [270]
Time B: 17:30 or 05:30 PM [1050]
added: 22:00 duration: -13:00

[A] [B] [X] x

=======================

Press <RETURN to close this window…
Note: Time arithmetics are done by converting each time pair (hr, min) to minutes since midnight, arithmetics are done on the minutes units and then converted back to time.

It will be better if you follow the functions below.

bool time_is_valid(int hr, int min); //true if hr:min is valid
bool time_is_valid(int hr, int min, char ap); //true if hr:min [ap]m is valid

void time_input(int& hr, int& min, char &ap, string prompt = “:”); //input hr:min ap
void time_input(int& hr, int& min, string prompt=”:”); //input hr:min

void time_output(int hr, int min); //output hr:min
void time_output(int hr, int min, char ap); //output hr:min ap

void time_convert(int hr_24, int& hr_12, char &ap); //hr:min – hr:min ap
void time_convert(int hr_12, char ap, int& hr_24); //hr:min ap – hr:min

void time_add(int& hr_start, int& min_start, int hr_duration, int min_duration); //hr:min += hr:min
void time_add(int hr_start, int min_start, int hr_duration, int min_duration, int& end_hr, int& end_min); //end_time = t1+t2

void time_subtract(int &hr_end, int &min_end, int hr_start, int min_start); //hr:min -= hr:min
void time_subtract(int hr_end, int min_end, int hr_start, int min_start, int& hr_duration, int& min_duration); //hr:min -= hr:min

void time_minutes_to_time(int mins, int& hr, int& min); //hr:min – mins
int time_time_to_minutes(int hr, int min); //mins since midnight

More products