Problem

If you developed a Fraction structure for Teacher’s Pet Software. The structure contains t...

If you developed a Fraction structure for Teacher’s Pet Software. The structure contains two public data fields for numerator and denominator. Add a third field that can hold the whole-number portion of a Fraction. Write a main()function in which you create three Fraction objects. Prompt the user for values for each field of two of the Fractions. Add statements to the main()function to do the following:

» If the user enters a 0 denominator for a Fraction, force it to be 1.


» Display each Fraction. If the whole-number portion is greater than 1, use it in the output, but if the whole-number portion is 0, just display the fraction portion. For example, a Fraction with value 0 1/3 should display as 1/3. If the numerator of a Fraction is 0, then just display the whole-number portion; for example, if the user enters 2 0/3, just display 2. If the whole-number portion is 0 and the numerator is 0, as in 0 0/2, then just display 0.


» Determine whether the value of the first Fraction is greater than, equal to, or less than the value of the second Fraction. For example, 1/2 and 3/6 are equal. As another example, 1 1/2 and 0 3/2 also are equal. Display an appropriate message indicating the results.


» Determine whether each entered Fraction is more than 1, and reduce the Fraction if it is. For example, 7/2 should be reduced to 3 1/2, and 10/4 should be reduced to 2 2/4 (in other words, you do not need to reduce it to 2 1/2). If the Fraction is not more than 1, then set the whole-number field to 0. Display the reduced Fraction.


» Prompt the user to enter an arithmetic operation: +, or *. Calculate the third Fraction to be the result of applying the requested operation to the two entered Fractions. Display the result as a whole number, if any, and the fractional part, if any. For example, adding 1/4 and 1/4 results in 2/4 (you do not need to reduce 2/4 to 1/2), subtracting 1/5 from 3/1 results in 2 4/5, and multiplying 1/3 by 6/1 results in 2. Display the results.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT