Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USING C++ You have been developing a Fraction class for Teachers Pet Software using C++. Each Fraction contains a numerator, denominator, a whole number portion,

USING C++

You have been developing a Fraction class for Teachers Pet Software using C++. Each Fraction contains a numerator, denominator, a whole number portion, and access to several functions you have developed, including overloaded operators.

a. Create a MathProblem class that holds fields for four Fraction objects: the first Fraction operand in a problem, the second Fraction operand in a problem, the users answer to a problem, and the correct answer to a problem. The MathProblem class also contains a character field that stores an operator (such as +), and contains an integer or bool field named isAnswerCorrect, indicating whether the user correctly answered the problem. For example, a MathProblem object containing 1/2, +, and 1/4 for the operands and operator, 3/4 for the correct answer, and 3/8 for the users answer would contain a 0 or false in the isAnswerCorrect field. However, if the users answer was 3/4, isAnswerCorrect would be true.

b. Include a function named setProblem()that sets a MathProblems values with arguments that include two Fraction operands and an operation. This function calculates and stores the correct answer, assigns 0 to the users answer, and sets isAnswerCorrect to false. Include a displayProblem()function that displays the math problem as a question, and an askUserForAnswer()function that accepts the users answer from the keyboard and assigns an appropriate value to isAnswerCorrect.

c. Include any other MathProblem functions you feel are useful and appropriate.

d. Write a main()function that declares five MathProblem objects you can use to test a students fraction arithmetic skills. Assign random Fraction values to the MathProblems, choosing any appropriate limits for the numerators and denominators. In a loop, display the problems using an operation of your choice (for example, the problems might all be addition problems) and accept the answers. When the five problems are completed, display the problems, along with the students answer, the correct answer, and a message indicating whether the student is right or wrong. Finally, show the student a score indicating the percentage of problems answered correctly. Save the file as MathProblems.cpp.

e. Create a class named DoublingMathProblem that derives from MathProblem. The DoublingMathProblem class includes a setProblem()function that overrides its parents setProblem()function. This version requires a single Fraction argument; this argument is used as both the first and second operand in a problem. The operator for a doubling problem is always +. In other words, each DoublingMathProblem is a problem such as 1/3 + 1/3 where a Fraction value is doubled

. f. Write a main()function that declares five DoublingMathProblem objects you can use to test a students fraction arithmetic skills. In a loop, display the problems and accept the answers. When the five problems are completed, display the problems, along with the students answer, the correct answer, and a message indicating whether the student is right or wrong. Finally, show the student a score indicating the percentage of problems answered correctly. Save the file as DoublingMathProblems.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

More Books

Students also viewed these Databases questions