Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You have been developing a Fraction class for Teachers Pet Software that contains several fields and functions. a. Add four arithmetic operators, +, -, *,

You have been developing a Fraction class for Teachers 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 drilladdition, 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

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions

Question

=+is likely to adversely affect the resilience of the organization.

Answered: 1 week ago