Question: Java Write a program that demonstrates causing and throwing the following exceptions. ArithmeticException InputMismatchException ArrayIndexOutOfBoundsException StringIndexOutOfBoundsException NullPointerException NegativeArraySizeException The program should present the user with
Java
Write a program that demonstrates causing and throwing the following exceptions. ArithmeticException InputMismatchException ArrayIndexOutOfBoundsException StringIndexOutOfBoundsException NullPointerException NegativeArraySizeException The program should present the user with a numbered menu that extends the capability to the user to select one of the above exceptions. Menu selection is run through a switch/case structure. Each case creates an instance of a class associated with the one of the above exceptions. Each class constructor contains try/catch/finally block(s) that includes any input needed to force the exception and outputs messages indicating the type of exception thrown, the values and/or condition(s) causing the exception, and name of the class throwing the exception.
Do not prompt the user for any input other than menu item number. Use hard coded literal values for data required for variables and member variables, class constructor calls, and other program variables. Your program(s) must include the following: 1. Tell the user how to terminate prompted input of unspecified length. 2. Include description of what user is being prompted for each input. 3. Include description of units when appropriate, i.e., .05 or 5 for 5%.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
