Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(C++ Programing Language) For this assignment you are to implement a program that can be used to convert a calendar date in the form m/d/y

(C++ Programing Language)

For this assignment you are to implement a program that can be used to convert a calendar date in the form m/d/y where m denotes the month, d denotes the day of the month, and y denotes the year to an ordinal date of the form y-d, where y denotes the year and d denotes the day of the year. For a calendar year the value of m is in the range 1-12. The value of d is in the range 1 - 28, 29, 30 or 31, depending on the value of m and y. The value of y can be any valid year. For an ordinal date the value of y can be any valid year, and the value of d is in the range 1 - 365, 366 for a non-leap year or leap year, respectively.

Your program should include the following functions:

void ReadDate(int &m, int &d, int &y);

This function prompts for and reads a calendar date from the user and passes the month, day and year of that calendar back to the calling program using the parameters m, d, and y, respectively.

int OrdinalDay(int m, int d, int y);

This function returns the ordinal day corresponding to the calendar date m/d/y.

bool IsLeapYear(int y);

This function returns the value true if y is a leap year, and returns the value false if y is not a leap year.

Using the above functions, you are to implement a program that begins by asking the user the number of dates that are to be processed. Once the user has specified the number of dates, say n, you are to then prompt the user n times to input a calendar date in the format m/d/y. For each date input by the user, your program should output the equivalent ordinal date.

Once all of the values have been processed, the program should inform the user that all n dates have been processed (specify the number) and terminate.

Sample Output Window for this Programming Assignment

Enter the number of dates to be processed: 5

Enter a date value (mm/dd/yyyy) to be converted: 10/22/2017

10/22/2017 = 2017-295

Enter a date value (mm/dd/yyyy) to be converted: 1/1/2017

1/1/2017 = 2017-1

Enter a date value (mm/dd/yyyy) to be converted: 3/1/2016

3/1/2016 = 2016-61

Enter a date value (mm/dd/yyyy) to be converted: 3/1/2017

3/1/2017 = 2017-60

Enter a date value (mm/dd/yyyy) to be converted: 12/31/2000

12/31/2000 = 2000-366

The number of dates processed: 5

Press any key to continue . . .

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_2

Step: 3

blur-text-image_3

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions

Question

Describe several models for organizing a human resources department

Answered: 1 week ago

Question

3 How the market system answers four fundamental questions.

Answered: 1 week ago

Question

5 The mechanics of the circular flow model.

Answered: 1 week ago