Can you helo me Fix the typo in the following program. My solution should be a single line of code with the typo fixed: public class Rational { private int numerator; private int denominator; public Rational(int numerator, int denominator) { this.numerator = numerator; this.denominator = denominator; } public int getNumerator(){ return this.numerator; } public int getDenominator(){ return this.denominator; } public double getFraction(){ return (double)numerator / (double)denominator; } public String toString(){ return numerator+"/"+denominator; } public static void main(String[] args) { Rational r = new Rational(2,3); System.out.println(r); double real = getFraction(); System.out.println(real); } }
Can you helo me Fix the typo in the following program. My solution should be a single line of code with the typo fixed:
public class Rational
{
private int numerator;
private int denominator;
public Rational(int numerator, int denominator)
{
this.numerator = numerator;
this.denominator = denominator;
}
public int getNumerator(){ return this.numerator; }
public int getDenominator(){ return this.denominator; }
public double getFraction(){
return (double)numerator / (double)denominator;
}
public String toString(){
return numerator+"/"+denominator;
}
public static void main(String[] args)
{
Rational r = new Rational(2,3);
System.out.println(r);
double real = getFraction();
System.out.println(real);
}
}
Thank you!
Step by step
Solved in 4 steps with 2 images