Question: 9 . 6 ( Rational Class ) Create a class called Rational for performing arichmetic with fractions.Write a program to test your class. Use integer

9.6(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 1 in the numerator and 2 in the denominator. Provide public member functions that perform each of the following tasks:a)add-Adds two Rational numbers. The result should be stored in reduced form.b)subtract-Subtracts two Rational numbers. Store the resule in reduced form. nultiply-Multiplies two Rational numbers. Store the result in reduced form. divide-Divides two Rational numbers. The result should be stored in reduced form.e)toRationalString-Returns a string representation of a Rational number in the form a/b, where a is the numerator and b is the denominator.f)toDouble--Returns the Rational number as a double.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!