Problem

You have been developing a Fraction class for Teacher’s Pet Software that contains several...

You have been developing a Fraction class for Teacher’s Pet Software that contains several fields and functions.

a. Add four arithmetic operators, +, -, *, and /. Remember that to add or subtract two Fractions, you first must convert them to Fractions with a common denominator. You multiply two Fractions by multiplying the numerators and multiplying the denominators. You divide two Fractions by inverting the second Fraction, then multiplying. After any arithmetic operation, be sure the Fraction is in proper format; for example, 1/2 * 2/3 results in 1/3, not 2/6.


b. Add an operator==()function that compares the value of two Fractions.


c. Add operator>()and operator<()functions that compare the values of two Fractions.


d. Add extraction and insertion operators for the Fraction class.


e. Write a main()program that declares an array of 10 randomly generated Fraction values, for which each numerator is a random value between 1 and 5 inclusive. (Instructions on generating random numbers appear in Appendix E.) Assign the value 10 to the denominator of each Fraction. Reduce each of the 10 randomly generated Fractions to its proper form (for example, 2/10 is 1/5) and display them. Save the file as FractionPartE.cpp.


f. Remove the statements from main()that display the 10 Fraction objects. Add statements to the main()function that prompt the user to choose between four operations for an arithmetic drill—addition, subtraction, multiplication, or division. After the user has selected an operation, generate five problems using five pairs of Fractions from the 10-element array. (If the user selects the subtraction option, make sure the first operand in the problem is not smaller than the second so that the correct answer is not negative.) Display a problem (for example, if the user chooses addition, the problem might be “1/10 + 3/10”) and allow the user to enter an answer from the keyboard. After each keyboard answer, notify the user whether the answer was correct. Save the file as FractionPartF.cpp.


g. Add code to the main()function that allows the user up to three attempts to correctly answer each problem. Save the file as FractionPartG.cpp.


h. Add code to the main()function that keeps score. At the end of the program, display a message similar to “You got 3 correct out of 5 problems”. Save the file as FractionPartH.cpp.


i. Alter the main()function to generate random numbers between 6 and 10 inclusive for the denominators. Save the file as FractionPartI.cpp.

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