Job Implement Following Methods Fraction Class Public Void Add Fraction Public Void Subtra Q43857083
YOUR JOB:
Implement the following methods in the Fraction class:
public void add(Fraction other)public void subtract(Fraction other)public void multiply(Fraction other)public int getNumerator()public int getDenominator()public void setNumerator(int x)public void setDenominator(int x)public String toString()Use the FractionTester file to test as you go along.
HINTS:
Note that
public void add(Fraction other)public void subtract(Fraction other)public void multiply(Fraction other)are void methods. They do not return anything. These methodsshould not create a new Fraction and return it.
Instead, these methods should modify the instance variables tobe added, subtracted, or multiplied by the Fraction other.
For example, if you had the following code in yourFractionTester class:
Fraction first = new Fraction(1, 2);Fraction second = new Fraction(1, 3);System.out.println();
System.out.println(“BEFORE:”);System.out.println(“first: ” + first);System.out.println(“second: ” + second);
first.multiply(second);
System.out.println(“AFTER:”);
System.out.println(“first: ” + first);System.out.println(“second: ” + second);Running should print out:
BEFORE:first: 1 / 2second: 1 / 3
AFTER:first: 1 / 6second: 1 / 3The Fraction first was modified by being multiplied by theFraction second. first was affected, second was not. 1/2 became 1/6because it was multiplied by 1/3.
please use Java
Expert Answer
Answer to YOUR JOB:Implement the following methods in the Fraction class:public void add(Fraction other)public void subtract(Fract…
OR