subject

Create a class called Date that has integer data members to store month, day, and year. The class will have a 3-parameter constructor that 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)
• The year must be between 1950 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 displays the date in the format "Month DD, " (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.

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 10:40, almaga1979orfvwo
5. illustrate how fine-line inventory classification can be used with product and market segments. what are the benefits and considerations when classifying inventory by product, market, and product/market?
Answers: 2
image
Computers and Technology, 23.06.2019 12:00, anamatiascamaja
If you embed a word table into powerpoint, what happens when you make edits to the embedded data? a. edits made to embedded data change the data in the source file; however, edits made to the source file will not be reflected in the embedded data. b. edits made to embedded data will change the data in the source file, and edits made to the source file will be reflected in the embedded data. c. edits made to embedded data don't change the data in the source file, nor will edits made to the source file be reflected in the embedded data. d. edits made to embedded data don't change the data in the source file; however, edits made to the source file will be reflected in the embedded data.
Answers: 1
image
Computers and Technology, 23.06.2019 20:30, kaylee2828
Column a of irma’s spreadsheet contains titles for each row, but her document is too big and will be printed three pages across. she wants to be sure that every page will be understood. what can irma do to with this problem?
Answers: 3
image
Computers and Technology, 24.06.2019 02:20, isabelsmhl
Peter is thinking of a number which isless than 50. the number has 9 factors. when he adds 4 to the number, itbecomes a multiple of 5. what is thenumber he is thinking of ?
Answers: 1
You know the right answer?
Create a class called Date that has integer data members to store month, day, and year. The class wi...

Questions in other subjects:

Konu
Mathematics, 04.01.2021 18:50