System.out.printf(“%4.1fn”, 8.);
System.out.printf(“%,.1fn”, 1234.567);
2. Assume that you have already successfully written a class named Fraction that handles fraction manipulations. You may assume that the Fraction class:
•Contains two instance variables – numerator and denominator.
•Contains a 2-parameter constructor that initializes the numerator and denominator instance variables.
•Contains this main method:
public static void main(String[] args)
{
Fraction c, d, e;
c = new Fraction(5, 8);
d = new Fraction(1, 2);
e = new Fraction(5, 8);
if (c.equals(d))
{
System.out.println(“c == d”);
}
if (c.equals(e))
{
System.out.println(“c == e”);
}
} // end main
Write a public method named equals for your Fraction class that tests whether two Fraction objects contain the same numerator and denominator values. Your equals method should be written such that the above main method would produce this output:
c == e
Only provide code for the asked-for equals method; do not provide code for the entire Fraction class!





