Question: Modify the Numbers.java file to implement the proper exception handling and add the correct processing. Create a new exception, StringNotANumberException. Your NumberTester should catch this

Modify the Numbers.java file to implement the proper exception handling and add the correct processing. Create a new exception, StringNotANumberException. Your NumberTester should catch this exception and determine which string is not a number and pass 0 back to the add method for it. If both strings are not a number, the sum should be 0. Your number tester should print the sum of each call. Your NumberTester must pass both String and int arguments to the Number class so that your exception will be exercised.

Hints: Use a string when you throw your StringNotANumberException to help you determine which parameter is not a number. Add a method that will loop around your call to add() until you have valid values.

Example output:

15 + 10 = 25

First is invalid

a + 10 = 10

First is invalid

Second is invalid

a + b = 0

Second is invalid

15 + b = 15

Submit the files StringNotANumberException.java, NumbersTester.java and Numbers.java

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!