You have to implement the concept of Exception Handling in Java. The final task is to return either the sum or difference of two numbers or the exception caught.
You’ve been provided with a starter code which contains sub-tasks as defined below:
Sub task 1: If n is a factor of x, display the sum of x and n. Otherwise, display the difference between x and n.
Sub task 2: Catch Arithmetic Exception if occurred and display the exception caught.
Sub task 3: Catch Number Format Exception if occurred and display the exception caught.
Sub task 4: Catch any other Exception occurred and display the exception caught.