Question: 9 . 6 ( Rational Class ) Create a class called Rational for performing arichmetic with fractions.Write a program to test your class. Use integer
Rational Class Create a class called Rational for performing arichmetic with fractions.Write a program to test your class. Use integer variables to represent the private data of the class the numerator and the denominator. Provide a constructor that enables an object of chis class to be inirialized when it's declared The constructor should contain defaule values in case no inicializers are provided and should store the fraction in reduced form. For example, the fractionAINwould be stored in the object as in the numerator and in the denominator. Provide public member functions that perform each of the following tasks:aaddAdds two Rational numbers. The result should be stored in reduced form.bsubtractSubtracts two Rational numbers. Store the resule in reduced form. nultiplyMultiplies two Rational numbers. Store the result in reduced form. divideDivides two Rational numbers. The result should be stored in reduced form.etoRationalStringReturns a string representation of a Rational number in the form ab where a is the numerator and b is the denominator.ftoDoubleReturns the Rational number as a double.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
