Need a hand with some method logic here, I got all the code written but I am having an issue trying to get this logic to work. These two methods are designed to simplify fractions and convert improper fractions to mixed numbers ( two seperate methods). Take a look and let me know what you guys think. Thanks.
-Sky
Also, I am getting a compile error in the last method (simplifyFractions), compiler complains about a "unresolved symbol for the variable newdenomerator".
Cant seem to figure out what the deal is, I think it may have something to do with my return type being a string and newdenomerator being an int. GAH!
public String mixedFractionValue(int numerator, int denomerator) //Method to convert improper fraction to mixed number BEGIN
{
int wholeNumber = ( numerator / denomerator );
int partRemainder = ( numerator % denomerator );
return ("" + wholeNumber + partRemainder + "/" + denomerator );
} //End mixedFractionValue method
public String simplifyFractions ( int numerator, int denomerator) //Method to simplify fractions BEGIN
{
int factor = numerator;
while ( factor > 1)
{
if ( denomerator % factor == 0)
{
int newdenomerator = ( denomerator / numerator );
}
factor --;
}
return ( "" + factor + "/" + newdenomerator );
} //End simplifyFractions method