Define 3 constructors and a toString method, setters, and getters
Define arithmetic methods for add, subtract, multiply, divide, and negate. The negate method will return the negative of the calling Rational object – return new Rational (-num,denom);
Define logical methods for equals, notEquals, lessThan, lessThanOrEqual, greaterThan, and greaterThanOrEqual.
All negative values should be represented with the negative sign in the numerator – do this in the setDenom method and call it in the constructor.
Extra Credit: add a greatestCommonDivisor method to reduce a Rational number to its lowest terms. If you write this method, add the reduced values to your output. For example:
½ + ¾ = 10/8 reduced to 5/4
Run three times with the following data: (read in the data then use one of the constructors or the setter methods to fill objects with data)
Input 1: 1/2, 3/4 - entered as 1 2 3 4
Input 2: 1/2, 5/10 – entered as 1 2 5 10
Input 3: 3/-5, 2 – entered as 3 -5 2 1
Output (using the first set of numbers):
Rational 1 –>1/2 reduced to _______
Rational 2 -> 3/4 reduced to_______
½ + ¾ ______ reduced to_______
½ - ¾ ______ reduced to_______
½ * ¾ ______ reduced to_______
½ / ¾ ______ reduced to_______
- ½ ______ reduced to_______
½ == ¾ ______ print true or false
½ != ¾ ________ print true or false
½ > ¾ ______ print true or false
½ >= ¾ ______ print true or false
½ < ¾ ______ print true or false
½ <= ¾ ______ print true or false