1. Save classFraction in a file called classFraction.cpp.
2. Write the main function in a file called fractionExercises.cpp. You access class Fraction through the statement: #include “classFraction.cpp”. The main function consists of a do while loop that displays the following menu:
What type of exercise would you like to see?
+, -, * , or /
The user enters their choice (+, -, * , or /) into a variable named choice. If choice is ‘*’, then a function called multFraction() is called. This function is not part of class Fraction. It is found in the same file as the main function.
Function multFraction() generates a random multiplication exercise. Use: srand(time(0)), and rand()%15+1, to generate random integers between 1 and 15. Functions srand and rand are found in stdlib.
Ex: f1.set(rand()%15+1, rand()%15+1);
f2.set(rand()%15+1, rand()%15+1);
//The above code displays a random multiplication example
Next multFraction() prompts the user for the numerator and denominator of the answer. The function compares the user’s answer to the correct answer generated by a statement such as: corrAns = f1*f2; //where corrAns is of type Fraction.
The function tells the user if the answer is correct or not correct. Keep track of how
many questions the user has answered and how many they have answered correctly.
Display this information after the answer to each exercise is entered. Control is passed to
the main menu.
3. Finish class Fraction. It should contain the following member functions (methods):
two constructors
operator+,-,* and /
(You could add more methods as you need them.)
When classFraction is complete, then you can write functions addFraction(),
subFraction(), divFraction() (in addition to multFraction()).