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
AlgebraicFraction(num, 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.
multiply(otherFraction) 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 n from the numerator array list
remove n from the denominatory array list
Fraction multiplication algorithm
to multiply fractions a and b
combine the numerators of fractions a and b
combine the denominators of fractions a and b
make a new fraction with the combined numerators and denominators
(reduce)
Fraction multiplication example
abcdef times e r
combined numerator: )
combined denominator: (d e f a e r)
new fraction ( abcdfg )/(d e f a e r)
reduced: c g)/( e e r)
AlgebraicFraction - an object for holding

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!