Question: Got an assignment that I need your help with. Use C++ for this assignment (Dev-C++ preferred). Thanks in advance. This assignment is on Ratio Data
Got an assignment that I need your help with. Use C++ for this assignment (Dev-C++ preferred). Thanks in advance. This assignment is on Ratio Data Type, Part I: Class Structure.
.
Part I: Class Structure Create a class called Ratio for performing arithmetic with fractions. Write a program to test your class Use integer variables to represent the instance variables- the numerator and the denominator. The data members should be private. Provide appropriate accessor and mutator . functions. Provide a constructor that enables an object of this class to be initialized when it is declared. Provide a no-argument constructor with default values of 1 in case no initial values are provided. getDoubleValue is a public function that returns a double with the same value as the underlying Ratio number. This function should not accept any parameters. . Store the numerator and denominator as separate data members of the class. The numerator and denominator should be stored so that the ratio is always in reduced form. Fractions are said to be in reduced form if the greatest common divisor of the numerator and the denominator is 1. (For example, 3/6 is equivalent to 1/2 and would be stored by the class as 1 in the numerator and 2 in the denominator.) It will be necessary to reduce the ratio when an object is created (from the constructor) and whenever the numerator or denominator change in value (from the mutator functions). It is probably most efficient to make a function whose purpose is to reduce the current ratio by considering the numerator and denominator instance variables. Then the reduce function can be performed whenever it's needed
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
