Question
Run the program 3 times with three different results using the programming language C++ create a class called Date that has integer data members to
Run the program 3 times with three different results using the programming language C++ create a class called Date that has integer data members to store month, day, and year. The class will only have a single 3-parameter constructor which allows the date to be created by specifying the numerical month, day, and year. If the user creates a Date object when any of the values passed are invalid, an invalid argument exception should be thrown with appropriate text:
The month must be a valid month (1-12), The day must be in the appropriate range for that month (do not worry about leap years), and The year must be between 1900 and 2020.
Include mutator methods for setting the month, day, and year. These should also throw invalid parameter exceptions if invalid parameters are provided. Include a toString() method that returns the date in the format Month DD, YYYY (ex: August 22, 1984).
Create a program that utilizes this class to create and display dates based on user input. Utilize try-catch blocks to validate the user input. Demonstrate usage of the class and its embedded exception handling.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started