Question: Assignment 10: Exception Handling (Chapter 11) Create an Exception class called BadGuessException BadGuessException should be a sub-class of the Exception class [1 point] Create 2

 Assignment 10: Exception Handling (Chapter 11) Create an Exception class called

Assignment 10: Exception Handling (Chapter 11) Create an Exception class called BadGuessException BadGuessException should be a sub-class of the Exception class [1 point] Create 2 constructors [1 point] A default constructor in the BadGuessException class, that passes the message "Sorry, that was an invalid guess!" to the parent constructor using keyword super A param eterized constructor in the BadGuessException class that will pass the parameter to the parent constructor using keyword super. Create a class called GuessingGame Generate a random number between 1 and 10. Prompt the user to guess the number. Allow the user unlimited attempts to guess the number correctly. [1 point] Once the user guesses the number correctly, print out "YOU GOT IT! and print out how many tries it took the user to guess the number. [1 point] Using a try-catch block, add exception handling to your code. [2 points] o throw a BadGuessException if the user enters any number that is not between 1 and 10. Add another catch block to catch the exception thrown if the user enters an incorrect format for number they guessed, such as "five" or "5.0" This should prevent your program from crashing or throwing a run time excpetion. When this exception is caught, the program should not crash and should display "Sorry, you entered an invalid number format". [1 point]

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!