Question: Project 3 : Comparing Fractions ( 1 0 points ) Define a class named Fraction . This class will be used to represent a ratio

Project 3: Comparing Fractions (10 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, (e.g.,5/9). 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 1/3 and 20/60 are equal, so the method should returntrue.(If either denominator is 0, then returnfalse.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!