Question: C++ Design a class called Date that has integer data members to store month, day, and year. The class should have a three-parameter (day-of-month, month,
C++
Design a class called Date that has integer data members to store month, day, and year. The class should have a three-parameter (day-of-month, month, year) default constructor that allows the date to be set at the time a new Date object is created. If the user creates a Date object without passing any arguments , or if any of the values passed are invalid, the default values of 1, 1, 2001 (i.e., January 1, 2001) should be used (see below for the definition of invalid values ). The class should have member functions to print the date in the following formats:
3/15/13 (printNumerical)
March 15, 2013 (printMonthFirst)
15 March 2013 (printDateFirst)
For the purposes of this exercise, the following are invalid values :
For day of month: any value less than 1 or greater than 31 (so February 30 or April 31 would be acceptable)
For month: any value less than 1 or greater than 12
For year: any value less than 0
A)Write a program that uses the Date class you defined in 7.1a. The program prompts "date information: " and then reads three integers : the day of month. the month and the year. The program then prints the date three times, each time on a line by itself. The first time the date is in numerical format, the second in month-first format, and the third time in date first format. Here is one sample run:
date information: 15 3 2014 3/15/2014 March 15, 2014 15 March 2014
Note: Do not define the class here-- just write the program that uses it.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
