Objective: 1. Download the interface Num ( https://cse.sc.edu/~pade/csce145/assi
ID: 3682505 • Letter: O
Question
Objective:
1. Download the interface Num (https://cse.sc.edu/~pade/csce145/assign/HW08/Num.java)
2. Write a class Int that extends Num. This class should have a single instance variable. It should also override definitions for the following methods:
----getApproxVal
----compare
----toString
In addition, you should have a constructor and a method getVal that returns the exact value of the Int as a Java primitive (int).
3. Write a java class Rational that has two instance variables:
----Int numer : The numerator
----Int denom : The denominator
This class should override definitions for the same 3 methods as above. In addition it should have a constructor that takes two ints as well as the following methods (to replace getVal in Int):
----getNumer
----getDenom
4. Finally, write a class InvalidDenomException that extends RuntimeException. Modify the constructor in Rational to throw an InvalidDenomException if anyone tries to set the denominator to zero.
You do not need a main method for this assignment. If you wish to test your code, you may use the test class provided here: TestNumbers (https://cse.sc.edu/~pade/csce145/assign/HW08/TestNumbers.java)
As a final note, make sure that in all your compare methods you compare by the actual values of the numbers, not by the values returned by getApproxVal.
Example:
This is example output given the provided test program
Finally:
Submit Int.java, Rational.java, and InvalidDenomException.java to the dropbox