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 11:30
In cell h5 enter a formula that will calculate the percentage of attendees that went to the altamonte springs job fair in 2018.
Answers: 1
question
Computers and Technology, 23.06.2019 15:00
1. which of the following statements are true about routers and routing on the internet. choose two answers. a. protocols ensure that a single path between two computers is established before sending packets over it. b. routers are hierarchical and the "root" router is responsible for communicating to sub-routers the best paths for them to route internet traffic. c. a packet traveling between two computers on the internet may be rerouted many times along the way or even lost or "dropped". d. routers act independently and route packets as they see fit.
Answers: 2
question
Computers and Technology, 23.06.2019 16:00
Kenny works with an it company. his company is about to launch new software in the market. he has to ensure that this new software is functional and meets all of the quality standards set up at the planning stage. which job profile is kenny likely to have? kenny is likely to have the job profile of a blank .
Answers: 2
question
Computers and Technology, 24.06.2019 01:00
Verify each identity[tex] \frac{csc}{cot \: x \: + \: tan \: x} = cos \: x[/tex]
Answers: 1
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
Mathematics, 02.06.2021 21:00
question
Mathematics, 02.06.2021 21:00
question
Law, 02.06.2021 21:00
question
Computers and Technology, 02.06.2021 21:00
question
Mathematics, 02.06.2021 21:00
question
Mathematics, 02.06.2021 21:00
Questions on the website: 13722363