Question: Project 3 : Comparing Fractions ( 1 0 points ) Define a class named Fraction . This class will be used to represent a ratio
Project : Comparing Fractions points
Define a class namedFraction This class will be used to represent a ratio of twointegers both stored in each object of the class as instance variables.
Include the following methods in your class:
a constructor which sets the values of of the numerator and denominator.
getter and setter methods which allow the user to access and change the numerator and the denominator of the fraction.
A method namedshowFractionwhich displays the fraction on the screen as a ratio, eg This method shouldnotreduce the fraction to lowest terms.
public String showFraction
return numerator denominator ;
Anequalsmethod which takes as a parameter anotherFractionobject and returnstrueif the two fractions represent the same real value andfalseotherwise For example, the two fractions and are equal, so the method should returntrueIf either denominator is then returnfalse
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
