This program is an extension of homework 2. Now the Fraction class becomes more clever and powerful. We now (you may have already done so) represent fractions in normal form: the denominator must be positive, numerator and denominator must have no common factors (except 1). We can use the gcd method to make sure that numerator and denominator have no common factors. If two fractions are in normal form they are equal if they have the same numerator and same denominator. If you have not yet done so, add methods to subtract, multiply, and divide Fractions. In addition write the methods
public boolean equals(Fraction a); // if this has value // equal to a return true otherwise false. public Fraction clone(); // Applied to the fraction 1/2, returns a new // Fraction with numerator 1 and denominator 2 public double value(); // Applied to the fraction 3/4 returns 0.75. public int compareTo(Fraction a); // If this has value less than a, // return -1, if equal to a, return 0, otherwise // return 1.You remember that we do not allow a fraction to have 0 as denominator. So be sure that if in a constructor, or in readFraction, or in setDenominator, or in division we have a fraction with 0 as denominator, then we replace it with the fraction 0/1.
Your main program should test (i.e. use) all of your methods!
Email your program to the Teaching Assistant.