0

My code is almost complete but I must figure out why my "reduceToLowestTerms() "doesn't get implemented through my code and make sure every time i enter a Fraction it does it.

My code is a little long so I will be posting the link! https://gist.github.com/anonymous/0421493909708268ea9e

private void reduceToLowestTerms()
{
    this.switchSign();
    int i1 = greatestCommonDivisor(this.numerator, this.denominator);
    this.numerator = this.numerator / i1;
    this.denominator = this.denominator / i1;
}   // end reduceToLowestTerms

private int greatestCommonDivisor(int integerOne, int integerTwo)
{
     int result;

     if (integerOne % integerTwo == 0)
        result = integerTwo;
     else
        result = greatestCommonDivisor(integerTwo, integerOne % integerTwo);

     return result;
}   

This is the code section that for some reason isnt being implemented throught the rest of my code How do i make sure all my fractions are in their lowest terms?

  • Probably no one will read through that much code. Please post the relevant code snippets here on Stackoverflow and some more background information (details). – home Mar 02 '14 at 07:14
  • kk i will edit this post! – user3369798 Mar 02 '14 at 07:14
  • @user3369798 cant understand the issue.Can u plz explain – Kick Mar 02 '14 at 07:51
  • @NiksTyagi When i run the code if i have a fraction that is 2/4 it does not reduce to 1/2 and im not sure why – user3369798 Mar 02 '14 at 07:53
  • i m slightly confuse.2 main method in the project.Fraction and assignment_1 class – Kick Mar 02 '14 at 07:54
  • @NiksTyagi I eddited fraction but my main class is Assignment1 – user3369798 Mar 02 '14 at 08:04
  • i dnt found any issue in the 2 mthod that is pasted.How do u knw that it is not giving correct answer.Which method u use to c the result.The class is soo big to identify everything – Kick Mar 02 '14 at 08:06

0 Answers0