Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write a program that creates an exception class called InvalidMonthException designed to be thrown when a user enters an invalid month and then create an

write a program that creates an exception class called InvalidMonthException designed to be thrown when a user enters an invalid month and then 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 month 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 their 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 months.

This is all in Java.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions

Question

=+8. Why is productivity important?

Answered: 1 week ago

Question

=+ 9. What is inflation and what causes it?

Answered: 1 week ago

Question

=+6. What does the invisible hand of the marketplace do?

Answered: 1 week ago