Question: AlgebraicFraction - an object for holding abstract fractional representations. fields numerator: an ArrayList of each numerator component denominator: an ArrayList of each denominator component methods
AlgebraicFraction an object for holding abstract fractional representations.
fields
numerator: an ArrayList of each numerator component
denominator: an ArrayList of each denominator component
methods
AlgebraicFractionnum denom: The values of each cell of the num array should be put in to the
numerator ArrayList and the values of each cell in the denom array should be put into the denominator
ArrayList. Then the fraction should be reduced with the below Fraction reducing algorithm.
multiplyotherFraction should return a new AlgebraicFraction from the combination of the two
fractions. See Fraction multiplication algorithm.
toString : this method should return a String representation of the reduced fraction. The parts of the
numerator should be prefixed by a then separated by single spaces followed by and then the
parts of the denominator should be separated by spaces and then ended with a
Fraction reducing algorithm
For each Object n in the num array passed into the constructor:
if n is in the numerator ArrayList and n is in the denominator ArrayList
remove from the numerator array list
remove from the denominatory array list
Fraction multiplication algorithm
to multiply fractions a and b
combine the numerators of fractions a and
combine the denominators of fractions a and
make a new fraction with the combined numerators and denominators
reduce
Fraction multiplication example
times e
combined numerator:
combined denominator: e a e
new fraction abcdfg d e a e
reduced: c g e e r
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
