Question: In java: Write a program that creates an exception class called InvalidMonthException designed to be thrown when a user enters an invalid month. [5 points]

In java:

  1. Write a program that creates an exception class called InvalidMonthException designed to be thrown when a user enters an invalid month. [5 points]
  2. Create an application that asks users to input their birth month as an integer, and then prints a custom message. For example, it should display "You are born in October" if the user enters 10. You could create a String array and store the months of a year. So, the array elements will be January, February,...,December. Now, use a while loop to ask the user to enter a valid integer number between 1-12 corresponding to the birth month, until the user enters -1 to exit. Your program should throw an InvalidMonthException if the user enters a value not between 1-12. Handle the exception by printing an appropriate message, and then continue processing more month numbers.

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!