Question: ) Class name is Fraction has the attributes: numerator (an integer) and denominator (an integer). The methods should include a default constructor with default values

) Class name is Fraction has the attributes: numerator (an integer) and denominator (an integer). The methods should include a default constructor with default values of 1 for each attribute, a set function for each attribute, a setAll function that sets values for both attributes, a get function for each attribute, a decimalValue function that returns the quotient as a decimal, a ratioValue that returns the ratio (example: 3/7).

Create a class diagram

Create the class specification/interface

Create a class implementation

Constructor sets all of the attributes to 0

A set function for each attribute

The set function for denominator must validate parameter because it can not be 0. If 0, then set denominator to 1

A setAll function that accepts two integer and assigns them to the attributes

A get function for each attribute that returns the value of the attribute

A decimalValue function that returns the quotient as a decimal

A ratio function that returns the reduced ratio of numerator/denominator

Suppose the ratio is 6/14, the function will return the reduced equivalent of 3/7 as a string

Need to use a greatest common divisor algorithm

Add the class interface and implementation to a test driver

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 Databases Questions!