Java

TOPIC i05 – ERROR HANDLING 2 - ADVANCED

 

LESSON WORK

 

 

QUESTION #1


a) Create a NegativeNumberException that simply extends Exception.

 

b) Write a method called circumference that gets a radius and return the circumference of the corresponding circle. However, if the radius provided is negative, have your method throw a NegativeNumberException.

 

c) In the main method, use the try/catch structure to handle when a NegativeNumberException occurs.

 

d) Test your program.