Question: Write a Month class to hold a months name and number. The constructor accepts an integer argument and uses that integer to initialize the months

Write a Month class to hold a months name and number. The constructor accepts an integer argument and uses that integer to initialize the months number and name properly.

Write an programmer defined exception class InvalidMonthException for the following error condition:

- A number less than 1 or greater than 12 is given for the month number

- Modify the Month class in Q1 so that the constructor throws the appropriate exception when an invalid month number is given for the constructor

- Demonstrate the classes in a demo program.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!