![subject](/tpl/images/cats/informatica.png)
Computers and Technology, 13.08.2021 05:00 CutiePie6772
Write a FractionDemo program that instantiates several Fraction objects and demonstrates that their methods work correctly. Create a Fraction class with the following fields, all of type int:
* wholeNum - Holds a whole number
* numerator - The numerator
* denominator - The denominator
In addition:
* Create properties for each field. The set accessor for the denominator should not allow a 0 value; the value defaults to 1.
* Add three constructors. One takes three parameters for a whole number, numerator, and denominator. Another accepts two parameters for the numerator and denominator; when this constructor is used, the whole number value is 0. The last constructor is parameterless; it sets the whole number and numerator to 0 and the denominator to 1. (After construction, Fractions do not have to be reduced to proper form. For example, even though 3/9 could be reduced to 1/3, your constructors do not have to perform this task.)
* Add a Reduce() method that reduces a Fraction if it is in improper form. For example, 2/4 should be reduced to 1/2.
* Add an operator+() method that adds two Fractions. To add two fractions, first eliminate any whole number part of the value. For example, 2 1/4 becomes 9/4 and 1 3/5 becomes 8/5. Find a common denominator and convert the fractions to it. For example, when adding 9/4 and 8/5, you can convert them to 45/20 and 32/20. Then you can add the numerators, giving 77/20. Finally, call the Reduce() method to reduce the result, restoring any whole number value so the fractional part of the number is less than 1. For example, 77/20 becomes 3 17/20.
* Include a method named FracString() that returns a string that contains a Fraction in the usual display formatâthe whole number, a space, the numerator, a slash (/), and a denominator. When the whole number is 0, just the Fraction part of the value should be displayed (for example, 1/2 instead of 0 1/2). If the numerator is 0, just the whole number should be displayed (for example, 2 instead of 2 0/3).
![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, 22.06.2019 20:00, jayjay5246
What is the term for water wave that is created by an underwater earthquake
Answers: 1
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 01:30, solikhalifeoy3j1r
In deadlock avoidance using banker’s algorithm, what would be the consequence(s) of: (i) a process declaring its maximum need as maximum possible for each resource. in other words, if a resource a has 5 instances, then each process declares its maximum need as 5. (ii) a process declaring its minimum needs as maximum needs. for example, a process may need 2-5 instances of resource a. but it declares its maximum need as 2.
Answers: 3
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 08:00, seaotter7140
Michael has written an e-mail to his employees that describes a new product special that will be introduced to the customers next week. by taking time to make sure the e-mail is well written, logical, and organized, michael has made sure his message has the characteristics of a) effective communicationb) ineffective communicationc) barriers to communicationd) workplace communication
Answers: 2
You know the right answer?
Write a FractionDemo program that instantiates several Fraction objects and demonstrates that their...
Questions in other subjects:
![Konu](/tpl/images/cats/en.png)
English, 14.09.2020 19:01
![Konu](/tpl/images/cats/fr.png)
French, 14.09.2020 19:01
![Konu](/tpl/images/cats/mat.png)
Mathematics, 14.09.2020 19:01
![Konu](/tpl/images/cats/geografiya.png)
Geography, 14.09.2020 19:01
![Konu](/tpl/images/cats/mat.png)
Mathematics, 14.09.2020 19:01
![Konu](/tpl/images/cats/mat.png)
Mathematics, 14.09.2020 19:01
![Konu](/tpl/images/cats/mat.png)
Mathematics, 14.09.2020 19:01
![Konu](/tpl/images/cats/obshestvoznanie.png)
Social Studies, 14.09.2020 19:01
![Konu](/tpl/images/cats/mat.png)
Mathematics, 14.09.2020 19:01
![Konu](/tpl/images/cats/istoriya.png)
History, 14.09.2020 19:01