Question: Task: Add four instance methods to the public interface of class 'Fraction': This is what I tried, but it does not work: Error : Compilation

Task: Add four instance methods to the public interface of class 'Fraction':

Task: Add four instance methods to the public interface of class 'Fraction':

This is what I tried, but it does not work:

This is what I tried, but it does not work: Error: Compilation

Error:

Compilation error Main.java:10: error: illegal start of expression public Integer setDenominator(){ ^ Main.java:10: error: ';' expected public Integer setDenominator(){ ^ Main.java:13: error: illegal start of expression public Integer getNominator() { ^ Main.java:13: error: ';' expected public Integer getNominator() { ^ Main.java:16: error: illegal start of expression public Integer getDenominator() { ^ Main.java:16: error: ';' expected public Integer getDenominator() {

Add four instance methods to the public interface of class 'Fraction': an instance method 'getNominator()' which returns the value of the instance variable 'nominator', an instance method 'getDenominator()' which returns the value of the instance variable 'denominator', an instance method 'setNominator' which sets the value of the instance variable 'nominator', and an instance method 'setDenominator' which sets the value of the instance variable denominator'. class Fraction Integer nominator; Integer denominator; public Integer setNumerator() { return nominator; public Integer setDenominator() { return denominator; public Integer getNominator() { return nominator; public Integer getDenominator() { return denominator; class Main public static Fraction createFraction(Integer nominator, Integer denominator) Fraction result = new Fraction(); result.setNominator (nominator); result.setDenominator (denominator); return result; public static void main(String[] arguments) final Fraction HALF = createFraction(1, 2); final Fraction THREE_FIFTH = createFraction(3, 5); System.out.println(toString(HALF)); System.out.println(toString(THREE_FIFTH)); public static String toString(Fraction fraction) return fraction.getNominator() + "/" + fraction.getDenominator()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!