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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started