Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases

Authors: Ian Robinson, Jim Webber, Emil Eifrem

1st Edition

1449356265, 978-1449356262

More Books

Students also viewed these Databases questions

Question

Explain basic guidelines for effective multicultural communication.

Answered: 1 week ago

Question

Identify communication barriers and describe ways to remove them.

Answered: 1 week ago

Question

Explain the communication process.

Answered: 1 week ago