Docsity

ITK 179 Fall 2008 Programming Assignment 2: Exception Handling in Java - Prof. Chung-Chih , Assignments of Information Technology

Toggle sidebar
bg1
ITK 179, Fall 2008 Programming Assignment 2, 30 points
Due: Sep. 17 (Wednesday)
The purpose of this assignment is to practice exception handling by using try,throw,catch, and finally
in Java.
•Write a method with try,catch, and finally blocks and use a switch statement in the try block
to let the user select a case to demo one of the following exceptions:
1. ArithmeticException,
2. NullPointerException,
3. NumberFormatException,
4. ArrayIndexOutOfBoundsException,
5. IndexOutOfBoundsException, and
6. RuntimeException.
For IndexOutOfBoundsException and RuntimeException, you can define your own condition to
throw the exceptions. This should be done by using throw when certain conditions occur.
•You have to include a finally block at the end.
•Save your program file with name Asg2.java for submission. Note: follow the guideline.
Extra 10 points:
Implement this assignment on your Unix account. Put all your works in the directory /ITK179/Asg2 under
your home directory. (Note: Unix is case sensitive.) If you decide to do so, you have to change the mode
of the directory to readable for every one after the due date, so I can grade your work. You still have
to write up a report and submit a hard copy. However, you don’t have to websubmit your programs. You
have to keep your work in your account to the end of the semester.
Due: Sep. 17 (Wednesday) c
Chung-Chih Li P-1/1

Partial preview of the text

Download ITK 179 Fall 2008 Programming Assignment 2: Exception Handling in Java - Prof. Chung-Chih and more Assignments Information Technology in PDF only on Docsity!

ITK 179, Fall 2008 Programming Assignment 2, 30 points

Due: Sep. 17 (Wednesday)

The purpose of this assignment is to practice exception handling by using try, throw, catch, and finally in Java.

  • Write a method with try, catch, and finally blocks and use a switch statement in the try block to let the user select a case to demo one of the following exceptions: 1. ArithmeticException, 2. NullPointerException, 3. NumberFormatException, 4. ArrayIndexOutOfBoundsException, 5. IndexOutOfBoundsException, and 6. RuntimeException.

For IndexOutOfBoundsException and RuntimeException, you can define your own condition to throw the exceptions. This should be done by using throw when certain conditions occur.

  • You have to include a finally block at the end.
  • Save your program file with name Asg2.java for submission. Note: follow the guideline.

Extra 10 points:

Implement this assignment on your Unix account. Put all your works in the directory /ITK179/Asg2 under your home directory. (Note: Unix is case sensitive.) If you decide to do so, you have to change the mode of the directory to readable for every one after the due date, so I can grade your work. You still have to write up a report and submit a hard copy. However, you don’t have to websubmit your programs. You have to keep your work in your account to the end of the semester.

Due: Sep. 17 (Wednesday) ©c Chung-Chih Li P-1/