Answered step by step
Verified Expert Solution
Link Copied!

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':

image text in transcribed

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What are the most useful methods of initial selection?

Answered: 1 week ago

Question

Describe how language reflects, builds on, and determines context?

Answered: 1 week ago