Define a class fraction represent a ratio of integers


Discuss the below:

Q: Define a class called Fraction, used to represent a ratio of two integers.

1. Include mutator functions that allow the user to set the numerator and the denominator.

2. Also include a METHOD that displays the fraction on the screen as a ratio (e.g., 5/9). This method does not need to reduce the fraction to lowest terms.

3. Include an additional METHOD, "equals", that takes as input another Fraction and returns true if the two fractions are identical and false if they are not. This method should treat the fractions reduced to lowest terms; that is, if one fraction is 20/60 and the other is 1/3, then the method should return true.

4. Embed the class in a TEST PROGRAM that allows a user to create a fraction.

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Define a class fraction represent a ratio of integers
Reference No:- TGS01934926

Now Priced at $20 (50% Discount)

Recommended (94%)

Rated (4.6/5)