Java Program
Write a class for the following object.
Fraction - an object that represe...
![Computers and Technology](/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.
![answer](/tpl/images/cats/otvet.png)
Answers: 3
Other questions on the subject: Computers and Technology
![image](/tpl/images/cats/informatica.png)
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 02:00, ishmael9332
How are we able to create photographs differently than 100 years ago? explain your answer in relation to your photograph you selected.
Answers: 1
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 04:30, NEUROPHARMACOLOGICAL
The ieee 802.11: defines standards for wireless local area network (wlan) communication protocols. identifies various computers or devices connected to a network. verifies any resource attached to another computer on a network that is different from the computer to which the user is logged on. connects multiple local area networks (lans) and wide area networks (wans).
Answers: 2
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 08:00, nataliamontirl4230
Java the manager of a football stadium wants you to write a program that calculates the total ticket sales after each game
Answers: 1
Do you know the correct answer?
Questions in other subjects:
![Konu](/tpl/images/cats/en.png)
English, 26.07.2019 07:30
![Konu](/tpl/images/cats/mat.png)
![Konu](/tpl/images/cats/biologiya.png)
![Konu](/tpl/images/cats/obshestvoznanie.png)
![Konu](/tpl/images/cats/obshestvoznanie.png)
![Konu](/tpl/images/cats/himiya.png)
Chemistry, 26.07.2019 07:30
![Konu](/tpl/images/cats/ekonomika.png)
![Konu](/tpl/images/cats/ekonomika.png)
Business, 26.07.2019 07:30
![Konu](/tpl/images/cats/obshestvoznanie.png)
Social Studies, 26.07.2019 07:30
![Konu](/tpl/images/cats/istoriya.png)
History, 26.07.2019 07:30