Question: Implement a data type Rational for rational numbers that supports addition, subtraction, multiplication, and division. Use Euclid.gcd() (Program 2.3.1) to ensure that the numerator and
Implement a data type Rational for rational numbers that supports addition, subtraction, multiplication, and division.

Use Euclid.gcd() (Program 2.3.1) to ensure that the numerator and the denominator never have any common factors. Include a test client that exercises all of your methods. Do not worry about testing for integer overflow.
public class Rational Rational (int numerator, int denominator) Rational plus (Rational b) Rational minus (Rational b) Rational times (Rational b) Rational divides (Rational b) String toString() sum of this number and b difference of this number and b product of this number and b quotient of this number and b string representation
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
