public class StoreRatioNumberClass
{
private int num;
private int den;
public RationalNumber() //here
{
num = 0;
den = 1;
}
public RationalNumber(int newNum, int newDen) //and here, but it gives me 3 separate errors for it//
{
num = newNum;
den = newDen;
simplify();
}
private void simplify()
{
int gcd = gcd();
finalNum = num/gcd;
finalDen = den/gcd;
}
private static int gcd(int a, int b)
{
if (b == 0)
return a;
else
return gcd(b, a % b);
}
public double getValue()
{
return (double)num/den;
}
public String toString()
{
return(num + "/" + den);
}
}
My question is how do I solve this compiling issue on lines 7 & 11? This class takes the numerators and denominators entered in the main method class not shown here and simplifies the rational number with the GCD. Also, when I do put in a return type it just comes up with even more errors and warnings so I'm stumped! Thank you for looking and all of your inputs.
StoreRatioNumberClass
.