CSCI 201 Spring 2004

Short Homework Assignment 4

Your assignment is to modify the attached program, ExceptionsNow.java,so that all 6 of the exceptions that the program is designed to catch occur when the program is run. Several of the exceptions that this program catches were not dicusssed in class, but you can learn about them by looking at the Exceptions in the java.lang package in the on-line java documentation.

Right now the program runs without generating any exceptions; your job is to make the minimum number of changes to this code necessary to generate the 6 exceptions. The minimum number of characters that need to be changed (inserted or modified) to make this happen is 16 characters total! The minimum number of changes required to generate each exception is indicated in the comments in the code.

In order to receive full credit for this assignment, you must not make unnecessary changes to the code. For example, the change from "...carroll.substring(54);" to "carroll.substring(0);" requires that three characters change and this does not meet the minimum requirements. The change from "= 1234" to "= 0;//1234;" (a four character change) violates programming style conventions and will not result in full credit. (Note that "= 0; //1234;" is a five character change and is OK). Hint: You will need to use single-line comments to meet the minimum character change requirements for some of the exceptions.

You are encouraged to run this program to verify your results.

What to Turn In

Turn in a hard copy of the program ExceptionsNow.java with your changes marked on that code at the start of class on Wednesday April 28th.