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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 02:00, kelseybell5522
For a typical middle-income family, what is the estimated cost of raising a child to the age of 18? $145,500 $245,340 $304,340 $455,500
Answers: 1
image
Computers and Technology, 24.06.2019 22:00, josephvcarter
Is the process of organizing data to reduce redundancy. a. normalization b. primary keying c. specifying relationships d. duplication
Answers: 1
image
Computers and Technology, 25.06.2019 00:00, nisha87
Rom is designed for computer instructions temporary storage of data processing data
Answers: 1
image
Computers and Technology, 25.06.2019 08:00, Jroc23
What are good colleges to apply to if you got like a 2.5 as a gpa? already got a call back from gcu at least its a start rt
Answers: 2
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 in other subjects:

Konu
Mathematics, 09.09.2020 17:01
Konu
Mathematics, 09.09.2020 17:01
Konu
Mathematics, 09.09.2020 17:01
Konu
Mathematics, 09.09.2020 17:01
Konu
Mathematics, 09.09.2020 17:01
Konu
Mathematics, 09.09.2020 17:01
Konu
Mathematics, 09.09.2020 17:01
Konu
Mathematics, 09.09.2020 17:01
Konu
Mathematics, 09.09.2020 17:01
Konu
Mathematics, 09.09.2020 17:01