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, 24.06.2019 15:30
What is the total number of time zones that can be configured to show by default in a calendar in outlook 2016?
Answers: 1
question
Computers and Technology, 24.06.2019 19:00
Which of the following "invisible" marks represents an inserted tab?
Answers: 1
question
Computers and Technology, 24.06.2019 19:20
Kiesha has a worksheet with a range of cells using the following columns: name, score, group, study group, and date. kiesha needs to sort the worksheet on the date field. which option she use to most efficiently complete this task ? a use the cut and paste option to reorganize the data to fit that order b use the filter function to organize the data based on the date c use the order function to organize the data based on the date d use the sort function to organize the data based on date order
Answers: 3
question
Computers and Technology, 25.06.2019 02:00
Software and services are used to conceive, plan, and execute projects in any field. these tools are excellent methods of increasing the probability of successful projects. open source linux project management mind-mapping
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
question
History, 16.07.2021 02:10
question
English, 16.07.2021 02:10
question
Mathematics, 16.07.2021 02:10
question
Mathematics, 16.07.2021 02:10
question
Mathematics, 16.07.2021 02:10
Questions on the website: 13722360