Rational numbers. Implement an immutable data type Rational for rational numbers that supports addition, subtraction, multiplication, and division.
You do not have to worry about testing for overflow (see exercise), but use as instance variables two long values that represent the numerator and denominator to limit the possibility of overflow. Use Euclid’s algorithm to ensure that the numerator and denominator never have any common factors. Include a test client that exercises all of your methods.
Exercise
Robust implementation of rational numbers. Use assertions to develop an implementation of Rational that is immune to overflow.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.