Question: Define a class for a type called Fraction to represent a ratio of two integers. One member variable should represent the numerator, and one should

Define a class for a type called Fraction to represent a ratio of two integers. One member variable should represent the numerator, and one should represent the denominator. Include prototypes of the following member functions: 1) an input function that allows a user to supply a numerator and a denominator. 2) an output function that prints out the fraction in a nice format, such as "the fraction = 25/8" . 3) a set function that allows a program to set the numerator and the denominator. 4) a get function that returns the numerator value as an integer. 5) a get function that returns the denominator value as an integer. 6) a function that returns the fraction represented as a double . For example, if the numerator = 1 and the denomiator = 4, then the function should return 0.25. Use descriptive names for each of these member functions.

Write function definitions for each of the six member functions declared in the previous question. Make sure to write the headers in the correct form.

Write main program which you could use to could test each of the member functions for the Fraction class described in question above.

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 Databases Questions!