Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Time Library and Application: Write an application to produce the following output in C++ Note: User is presented with a menu of three items: change

Time Library and Application:

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  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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions