Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Date Library and Application Write an application to produce the following output (do this first): Note: User is presented with a menu of four

C++
Date Library and Application
Write an application to produce the following output (do this first):
Note: User is presented with a menu of four items: change date A, change date B, change number n or exit. Once the user inputs date A/B or n, the program shows the date arithmetics shown in the output.
Testing: Test your program thoroughly to make sure there are no bugs. Bugs you don't find will cost you (speaking from experience.)
======================
Date A: 02/01/1971
Date B: 01/01/1972
n: 10
[01/01/1972] - [02/01/1971] = 334
[02/01/1971] + [10] = 02/11/1971
[02/01/1971] - [10] = 01/22/1971
[A] [B] [N] [X] >> n
n: 10
Date A: 02/01/1971
Date B: 01/01/1972
n: 10
[01/01/1972] - [02/01/1971] = 334
[02/01/1971] + [10] = 02/11/1971
[02/01/1971] - [10] = 01/22/1971
[A] [B] [N] [X] >> b
: 1/1/80
Date A: 02/01/1971
Date B: 01/01/1980
n: 10
[01/01/1980] - [02/01/1971] = 3256
[02/01/1971] + [10] = 02/11/1971
[02/01/1971] - [10] = 01/22/1971
[A] [B] [N] [X] >> a
: 5/13/80
Date A: 05/13/1980
Date B: 01/01/1980
n: 10
[01/01/1980] - [05/13/1980] = -133
[05/13/1980] + [10] = 05/23/1980
[05/13/1980] - [10] = 05/03/1980
[A] [B] [N] [X] >> x
======================
Press to close this window...
Date Library:
Write the following functions to be used in this application or any application that may need date arithmetics.
Note:
* Date calculations envolve calculating the number of days between this date and the epoc (01/01/1970) This is a requirement.
* day_number: number of days since epoch
* year_number: number of days since epoch to Jan 1st of this year
* All day numbers are zero based, so 01/01/1970 is day 0 and 01/02/1970 is day 1
* avoid repeated code.
* Do a top/down design: Figure out what functions depend on which. Find out what functions are high level and what functions are low level
* Please check the correctness of your calculations (and indicate on the output that you have done so) using this or similar websites.
bool date_is_valid(int m, int d, int y); //true if m/d/y is valid
void date_input(int& m, int& d, int &y, //input a valid date with prompt
string prompt = ":");
void date_output(int m, int d, int y); //output mm/dd/yyy
void date_show(int m, int d, int y); //show all info about m/d/y
int date_day_number(int m, int d, int y); //days since epoch
int date_day_of_year(int m, int d, int y); //days since 01/01
int date_day_of_year_2_date(int days, //day of year -> m/d/y
int& m, int& d, int y);
void date_days_to_date(int days, //days since epoch -> m/d/y
int& m, int& d, int& y);
void date_add(int& m, int& d, int &y, int days); //date + n
int date_subtract(int end_m, int end_d, int end_y, //date - date
int start_m, int start_d, int start_y);
int date_days_in_month(int m, int y); //number of days in m/y
bool date_is_leap(int y); //true if y is a leap year
int year_size(int y); //365 or 366?
int num_of_leap_years(int y); //number of leap years since epoch
int year_number(int y); //#days from 01/01/1971 to 01/01/y

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

Murach's SQL Server 2012 For Developers

Authors: Bryan Syverson, Joel Murach, Mike Murach

1st Edition

1890774693, 9781890774691

Students also viewed these Databases questions

Question

4. How do rules guide verbal communication?

Answered: 1 week ago

Question

=+C&B (especially taxation) laws, regulations, and practices?

Answered: 1 week ago

Question

=+designing international assignment C&B packages.

Answered: 1 week ago