Lab 9 - I Take Exception to That Name(s): Date: Lab 9 - I Take Exception to That Algorithms & Data Structures I CSC 1051 Dr. Tom Way Introduction This lab is designed to give you experience working exception handling. This lab should be completed independently, although it's also ok to discuss it with classmates as long as you aren't copying each other's work. When completed, submit your results to Blackboard for this specific assignment. Be sure to upload your materials with the correct file names as described below. Objectives Practice causing exceptions to be thrown. Practice catching exceptions and responding to them. Practice researching how to cause exceptions of various type. Practice throwing an exception and observing exception propagation. Worth 100 points Due Monday, August 2, 2021 by 11:59 pm Lab Steps Part A - Write That Start by downloading the template Java program named TooManyProblems.java. In this program, add code inside each of the try-catch statements to cause the specific exception being caught to occur. Ideas on causing each of the exceptions required in the program: ArrayIndexOutOfBoundsException - declare an array of a known size then try to access a non-existent element. NullPointerException - initialize a string variable with a null value then try to invoke a method on it. ArithmeticException - try to divide an integer by 0 and assign the result to another integer. FileNotFoundException - try to create a FileReader (see Buffered Streams topic) with a file you know does not exist. NumberFormatException - use the Integer.parseInt() method to parse a string you know is not an integer. Programmer's Choice - try an Internet search for examples of Java exceptions and find a new one that you can cause to happen. Then, use the throw statement to "rethrow" the exception you caught and observe the output. When complete, the output should look something like this: Array index is out of bounds!
There's nothing there!
Can't divide a number by 0!
There's no file by that name!
That's not a number!
Something bad happened: java.lang.StringIndexOutOfBoundsException: String index out of range: 24
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 24 Compile and run your program to make sure there are no errors and it runs correctly. Make sure you have TooManyProblems.java ready to submit. Part B - Lab Submission When you have completed this lab, find the Lab 9 assignment on Blackboard and submit the following files (only java files and NOT class files): TooManyProblems.java Lab 9 Evaluation Name(s): Date: For reference, this is how points are awarded for all the parts of this assignment. Criteria Worth Score Cause and handle ArrayIndexOutOfBoundsException 15 Cause and handle NullPointerException 15 Cause and handle ArithmeticException 15 Cause and handle FileNotFoundException 15 Cause and handle NumberFormatException 15 Cause and handle different exception of your choice 15 Program compiles and runs correctly 10 Total 100