subject

In this , you must take your Fraction class from exercise 2.8.9 and extend it by adding a few handy methods. 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 methods should not create new Fraction and return it.
Instead, these methods should modify the instance variables to be added, subtracted, or multiplied by the Fraction other.
For example, if you had the following code in your FractionTester 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 / 2
second: 1 / 3
AFTER:
first: 1 / 6
second: 1 / 3
The Fraction first was modified by being multiplied by the Fraction second. first was affected, second was not. 1/2 became 1/6 because it was multiplied by 1/3.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 21:00
Uget brainliest if accurate mary has been given the responsibility of hiring a person for the position of a software testing officer. which management function would mary achieve this responsibility?
Answers: 1
question
Computers and Technology, 24.06.2019 13:30
What is the most important for you to choose before you build a network?
Answers: 1
question
Computers and Technology, 24.06.2019 13:50
Write a program that performs a simple n-body simulation, called "jumping leprechauns." this simulation involves n leprechauns, numberd 1 to n. it maintains a gold value g_i for each leprechaun i, which begins with each leprechaun starting out with a million dollars worth of gold, that is, g_i = 1000000 for each i = 1,. in addition, the simulation also maintains, for each leprachaun,i, a place on the horizon, which is represented as a double-precision floating point number, x_i. in each iteration of the simulation, the simulation processes the leprachauns in order. processing a leprachaun i during its iteration begins by computing a new place on the horizon for i, which is determined by the assignment:
Answers: 3
question
Computers and Technology, 24.06.2019 15:30
George is working as a programming team lead. which statements correctly describe the skills that he requires?
Answers: 3
You know the right answer?
In this , you must take your Fraction class from exercise 2.8.9 and extend it by adding a few handy...
Questions
question
English, 18.09.2020 05:01
question
Mathematics, 18.09.2020 05:01
question
Mathematics, 18.09.2020 05:01
question
Mathematics, 18.09.2020 05:01
question
Mathematics, 18.09.2020 05:01
question
Mathematics, 18.09.2020 05:01
question
Mathematics, 18.09.2020 05:01
question
Mathematics, 18.09.2020 05:01
question
Mathematics, 18.09.2020 05:01
question
Mathematics, 18.09.2020 05:01
question
Mathematics, 18.09.2020 05:01
question
Mathematics, 18.09.2020 05:01
question
Mathematics, 18.09.2020 05:01
question
Mathematics, 18.09.2020 05:01
question
Physics, 18.09.2020 05:01
question
Mathematics, 18.09.2020 05:01
question
Mathematics, 18.09.2020 05:01
question
Mathematics, 18.09.2020 05:01
question
Mathematics, 18.09.2020 05:01
question
Mathematics, 18.09.2020 05:01
Questions on the website: 13722363