You are asked to develop a relatively complete mathematical module on fractions. You are required to use OOP concepts ONLY.
Create a class called Fraction
Its data members are:
numerator, denominator, fraction_value, slash, whole_number.
Fraction_value: stores the fraction decimal value.
Slash: ("/"): is common to all Fraction objects, and will be used for a formatted display.
The function members:
A constructor: accepts two integer values. If only one parameter is passed, then assign it to the numerator, and force denominator to be 1. If no parameter is passed, use zero for the numerator and one for the denominator.
A constructor that accepts 3 arguments: a whole number portion of the fraction, a numerator, and a denominator.
Each constructor determines whether the fraction is more than 1.
If it is the case, compute the whole number and store it accordingly (may use additional methods/member functions where necessary).
Great Common Denominator: a function that finds the largest number that can divide evenly into both the numerator and denominator.
To reduce a Fraction: use a function that reduces a fraction to its proper format.
(27/12 - 9/4)
Whenever a fraction is created, automatically reduce the fraction to its proper format.
Display: displays the fraction's value as a floating point number and as a fraction.
Then include a whole number portion, a space, the numerator, a slash, the denominator:
Example: Fraction: 27/5 5 2/5
Fraction 3/8 3/8 (do not display the whole number if it is 0)
Fraction 0/5 0
Add four arithmetic operators +, -, *, and /.
NB: After any arithmetic operation, make sure the result is in proper format: e.g. 1/2* 2/3 = 1/3 (not 2/6)
Add the operators == (), >(), <(), that compare the values of two fractions
Prompt the user to choose between four operations for an arithemetic drill-- addition, substraction, multiplication, or division.
After a user has selected an operation, generate five problems using five pairs of fractions from a 10-element array.
Display a problem for (for example, if the user chooses addition, the problem might be "1/5 + 3/5") and allow the user to enter an answer from the keyboard.
After each keybord answer, notify the user whether the answer was correct.
Code a function that decalres an array of randomly generated Fraction values. For which each numerator is a random value between 1 and 5. Set the denominator to 10. Reduce the fraction to its proper form.
Hint: May want to use rand( ) % n
Allow the user up to three attempts to correctly answer each problem.
Keep score. Display a message similar to " No !, you got 3 correct out of 5 problems"
Test the above specification on an array of 10 randomly generated Fraction values between 6 and 10 inclusive for the denominators as well as numerators.
Please do email me d code....n thanks for your assistance.