Your task is to create a fraction calculator, so that a user can enter 2 fractions, and choose an operation (addition, subtraction, multiplication or division), and your program will tell them the answer in reduced form. You are expected to do this as described below:
Create a class named Fraction that has the following data members: numerator, denominator and sign. Numerator should be any number between 0 and 20, denominator should be any number between 1 and 20, and sign should be ‘p’ for positive or ‘n’ for negative. Create the appropriate ‘get’ and ‘set’ functions, as well as a default constructor, a display function and a reduce function.
Next, create a class named Problem that has the following data members: leftop, rightop and answer, where all 3 of these data members are of type Fraction. Note: this is composition (a ‘has a’ relationship) not inheritance (an ‘is a’ relationship). Create the appropriate ‘get’ and ‘set’ functions, as well as a display function and a ‘calculate answer’ function.
Create 4 derived classes (this is inheritance, ‘is a’ relationships) named AddProblem, SubProblem, MultProblem and DivProblem. Override the display and calculate functions to work properly for the different derived classes.
Finally, create a main program where you provide the user with the following menu:
1. Enter Left Fraction
2. Enter Right Fraction