Create a new Java project. This does not need to be a web application, but it ca
ID: 3691765 • Letter: C
Question
Create a new Java project. This does not need to be a web application, but it can be.
Create a class with one instance method that accepts two ints as parameters and does something simple with them, such as adding them together a returning the result.
Create two new exception classes: one checked, and one unchecked. Call the checked exception something innocent like "RandomInterruptionException" and call the unchecked exception something significant like "RandomCatastrophicException".
Using Math.random() modify your instance method as follows:
If either int is less than zero or greater than 1000 the method should generate a SEVERE log message and then throw an IllegalArgumentException (this exception is built in to Java, don't create it).
Generate a random number...
If the random number is between 0.0 and 0.1 then generate a WARNING log message and throw a RandomCatastrophicException.
If it's between 0.1 and 0.5 then throw a RandomInterruptionException.
Otherwise, just allow the method to resolve normally.
Create a main method (or Servlet/JSP if doing a web app) which allows the user to enter two integers for your new class's instance method. Do everything you can to prevent IllegalArgumentExceptions. Catch the RandomInterruptionException when it happens, generate a FINE log message, and retry the user's two numbers without letting the user know. Do not catch RandomCatastrophicException (allow it to crash your program/page), but make sure the message it displays is useful to the user.