next up previous
Next: What to turn in Up: Assignment 9: Rational Numbers Previous: An operator

Another modifier

1.
Write a method named reduce that reduces a rational number to its lowest terms by finding the GCD of the numerator and denominator and then dividing top and bottom by the GCD.
2.
Although most modifiers do not return anything, I thought it might be fun to make this one return something, just for variety. So, make reduce return the GCD (in addition to modifying the object).



Allen B. Downey
4/8/1998