Implement a data type Rational for rational numbers that supports addition, subtraction, multiplication, and division. Use Euclid.gcd()
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 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.
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Related Book For
Introduction To Programming In Java An Interdisciplinary Approach
ISBN: 9780672337840
2nd Edition
Authors: Robert Sedgewick, Kevin Wayne
Question Posted: