Computers and Technology

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.

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 10:00, adam4449
Jackson is teaching the decimal number system. he wants his students to know how to expand numbers by powers of 10. which is the correct order in which digits are assigned values in the decimal number system?
Answers: 1
image
Computers and Technology, 22.06.2019 21:30, GamerGirl15
This graph compares the total cost of attending educational institutions in texas. the graph demonstrates that the cost at private and public technical schools greatly varies.
Answers: 2
image
Computers and Technology, 23.06.2019 05:00, sharkboy578
Acompany is inviting design for its new corporate logo from its users. this is an example of ? a. crowdfunding b. crowdvoting c. crowdsourced design d. crowdtracking
Answers: 3
image
Computers and Technology, 23.06.2019 08:30, sofigaviria05
All of these are true about using adhesive except: a. dissimilar materials can be joined. b. mixing tips are product and material specific. c. a specific application gun may be required. d. two-part adhesives are dispensed using two mixing tips
Answers: 3
Do you know the correct 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, 20.09.2020 06:01
Konu
Computers and Technology, 20.09.2020 06:01
Konu
Mathematics, 20.09.2020 06:01