Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(Must be done in C++) You have been developing a Fraction class for Teachers Pet Software. Each fraction contains a numerator, a denominator, a whole

(Must be done in C++)

You have been developing a Fraction class for Teachers Pet Software. Each fraction contains a numerator, a denominator, a whole number portion, and a floating-point equivalent field. Each Fraction also has access to several functions you have developed.

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 * 2/3 results in 1/3, not 2/6.

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

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

Add extraction and insertion operators for the Fraction class.

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. You can generate a random number using an expression such as int randValue = rand() % highest;, where highest is one value higher than the largest number you want to generate. For example, rand() % 5 returns a random number between 0 and 4 inclusive. To generate a number between 1 and 5 instead of 0 and 4, you add 1 to randValue. Include to access the rand() function. For each Fraction, generate a random number for the numerator and assign the value 10 to the denominator. Reduce each of the ten randomly generated Fractions to its proper form (for example, 2/10 is 1/5) and display them.

Remove the statements from main() that display the ten Fraction objects. Add statements to the main() program that prompt the user to choose between for 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. 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.

Add code to the main() function that allows the user up to three attempts to correctly answer each problem.

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.

Alter the main() program to generate random number between 6 an 10 inclusive for the denominators as well as the numerators.

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

Database Systems Design Implementation And Management

Authors: Carlos Coronel, Steven Morris

14th Edition

978-0357673034

More Books

Students also viewed these Databases questions

Question

Do teachers across cultures differ in immediacy? Explain.

Answered: 1 week ago