Create a class Rational for performing arithmetic with fractions. Write a driver program to test the class. Provide a constructor that enables an object of this class to be initialized when it is instantiated. The constructor should contain default values in case no initializes are provided and should store the fraction in reduced form. Provide a private function to reduce numbers. Provide Public member functions for each of the following arithmetic’s functions (addition – subtraction – multiplication –division), printing in the form a/b, printing in floating point format and final overload the == and != operators to allow comparisons of two fraction numbers. Include any additional operations that you think would be useful for a rational number class.
Create a class Rational for performing arithmetic with fractions. Write a driver program to test the class. Provide a constructor that enables an object of this class to be initialized when it is instantiated. The constructor should contain default values in case no initializes are provided and should store the fraction in reduced form. Provide a private function to reduce numbers. Provide Public member functions for each of the following arithmetic’s functions (addition – subtraction – multiplication –division), printing in the form a/b, printing in floating point format and final overload the == and != operators to allow comparisons of two fraction numbers. Include any additional operations that you think would be useful for a rational number class.
Step by step
Solved in 2 steps