Java Program
Write a class for the following object.
Fraction - an object that represe...
![subject](/tpl/images/cats/informatica.png)
Computers and Technology, 23.02.2022 05:20 snap5236
Java Program
Write a class for the following object.
Fraction - an object that represents parts of a whole number. A fraction is created by supplying a numerator and a denominator.
Instance related actions
add - mutates this fraction by adding the other fraction value
subtract - mutates this fraction by subtracting the other fraction value
multiply - mutates this fraction by multiplying with the other fraction value
divide - mutates this fraction by dividing by the other fraction value
toString - represents the fraction in a form of "numerator/denominator"
compareTo - returns the following values
0 when this fraction is equal with the other fraction
1 when this fraction is greater than the other fraction
-1 when this fraction is less than the other fraction
Example
fraction1 = 1/2
fraction2 = 3/4
When fraction1.add(fraction2) is called, it will make the value of fraction 1 as 5/4.
When fraction1.subtract(fraction2) is called, it will make the value of fraction 1 as -1/4.
When fraction1.multiply(fraction2) is called, it will make the value of fraction 1 as 3/8.
When fraction1.divide(fraction2) is called, it will make the value of fraction 1 as 2/3.
When fraction1.compareTo(fraction2) is called, it will return -1.
When fraction2.compareTo(fraction1) is called, it will return 1.
![ansver](/tpl/images/cats/User.png)
Answers: 3
![](/tpl/images/ask_question.png)
![](/tpl/images/ask_question_mob.png)
Other questions on the subject: Computers and Technology
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 14:30, officialrogerfp3gf2s
Select the correct answer. a company wants to use online methods to target more customers. it decides to conduct a market research by collecting the data of a few customers with their consent. they want to track data of the sites that their customers frequently visit. which software can the company? a. spyware b. bots c. adware d. trojan horse e. rootkits
Answers: 1
![image](/tpl/images/cats/informatica.png)
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 16:00, CalCDanG
What is the biggest difference between section breaks and regular page breaks? section breaks are more difficult to add than page breaks. section breaks make it easier for you to view the document as an outline. section breaks allow you to have areas of the document with different formatting. section breaks are smaller than regular page breaks.
Answers: 2
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 16:00, nothingworksoutforme
Your is an example of personal information that you should keep private.
Answers: 1
You know the right answer?
Questions in other subjects:
![Konu](/tpl/images/cats/mat.png)
Mathematics, 13.03.2022 23:40
![Konu](/tpl/images/cats/istoriya.png)
![Konu](/tpl/images/cats/biologiya.png)
Biology, 13.03.2022 23:40
![Konu](/tpl/images/cats/mat.png)
Mathematics, 13.03.2022 23:40
![Konu](/tpl/images/cats/biologiya.png)
![Konu](/tpl/images/cats/himiya.png)
Chemistry, 13.03.2022 23:40
![Konu](/tpl/images/cats/mat.png)
Mathematics, 13.03.2022 23:40
![Konu](/tpl/images/cats/mat.png)
![Konu](/tpl/images/cats/fizika.png)