0

how to achieve that?

/** Task: Reduce this fraction to lowest term, i.e divide the numerator * and denominator by their Greatest Common Divisor * @return this fraction object */ public FractionInterface reduce(); /** Task: convert the fraction so that the sign is indicated by numerator. * exmaple: -3/-10 --> 3/10 3/-10 --> -3/10 * @return this fraction object */ public FractionInterface convert(); public FractionInterface reduce() { // implement this method! // // Outline: // compute GCD of num & den // GCD works for + numbers. // So, you should eliminate - sign // then reduce numbers : num/GCD and den/GCD // return this fraction object return null; } public FractionInterface convert() { // implement this method! // Adjusts the signs of the num and den so that // the num's sign is the sign of the fraction // and the den's sign is +. // return this fraction object Fraction newFraction = new Fraction(num,den); newFraction.num = num*-1; return null; }

18th Mar 2019, 1:30 AM
Chaoyi Ying
Chaoyi Ying - avatar
1 Respuesta
+ 7
You have full algorithm. So, I think implementation is not a big deal. Try implementing it and if u are facing any problem, then post ur code and ask. Give a try by yourself.
18th Mar 2019, 2:26 AM
Arushi Singhania
Arushi Singhania - avatar