Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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':
This is what I tried, but it does not work:
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started