** 1. Purpose: To gain experience using classes.
2. The Problem (an enhanced version of Chapter 11, Programming Problem 3, page 659): design, implement, and test a Rational class that represents a rational number as a pair of integers instead of a single floating-point number.
3. More Details:
A rational number is a number that can be expressed as a fraction whose numerator and denominator are integers. Examples of rational numbers are 0.75 (which is 3/4) and 1.125 (which is 9/8). The value p is not a rational number; it cannot be expressed as the ratio of two integers.
The Rational objects must be stored in their reduced form. In other words, the rational number 12/16 should be stored as 3/4. A private member function Reduce should be provided to reduce the Rational object.
The Rational class should have two class constructors. The first one lets the client specify an initial numerator and denominator. The other??"the default constructor??"creates the Rational number 0, represented as a numerator of 0 and a denominator of 1.
The Rational class should have arithmetic operations that add, subtract, multiply, and divide two Rational objects. These should be implemented as value-returning functions, each returning a Rational object.
The Rational class should have a Boolean operation that compares two Rational objects for equality.
The Rational class should have an input operation that reads a rational number from a designated input stream in the form numerator/denominator.
The Rational class should have an output operation that writes a rational number out to a designated output stream in the form numerator/denominator.
**4. Program Structures You are required to deploy "separate compilation," otherwise known as multi-file program development, which means that your program will reside in more than one source file. You must provide exactly three files for this project. All three files have been started for you but you must complete them as instructed below. In fact, the collection of files that have been provided are fully compilable, linkable, and executable with no warning or error messages. The user interface is completely functional but none of the rational number arithmetic has been implemented. DO NOT rename the files. The file names for this project are strictly defined and must not be altered. Click on the three hyperlinked file names below to view and download each file. . rational.h is the specification file and contains the definition of Rational class. This file is complete and requires no addition or modification. However, you ARE allowed to ADD (and only ADD) member functions to the class definition if you wish to do so [url removed, login to view] is the implementation file and must contain the implementation of Rational class member functions and any other supporting function. This file contains several provided functions but you must complete the file by adding the remaining Rational class member functions. There are two particular functions that will come in handy for this project. These functions (gcd and Reduce) are used to reduce a rational number to its smallest form. For example, a fraction 12/16 can be converted to 3/4 using these functions. The functions are provided in their entirety in the [url removed, login to view] file. There are two other functions provided in their entirety: the class default constructor and the function Read. [url removed, login to view] is the client file and contains function main and other supporting functions that are needed to use and, in this case, to test the functionality of the Rational class. This file is the test driver for Rational class and has already been started for you so that you have a basic menu-driven functionality. You must add the client code that uses the Rational class to allow the user full testing capability for your implementation. You must only fill the areas where it has been indicated "To be done by student." All required functions have been provided and no new functions are needed in this file. The student must only complete the main function. 5. Error Checking: Rational class member functions should check for a zero denominator and abort the program using the assert function if zero is input or formed in a calculation for the denominator. The client code must try to avoid operations that may result in a zero denominator Rational object. For example, the client code should not allow a rational number to be divided by another rational number of zero value. 11. Output: This test driver works with up to two fractions acting as operands for various operations. These operands are left and right operands of an arithmetic operation. Let's call the operands "LEFT" and "RIGHT". LEFT = RIGHT = Enter the character in (parentheses) to choose an operation: (+) Add LEFT and RIGHT (-) Subtract RIGHT from LEFT (*) Multiply LEFT by RIGHT (/) Divide LEFT by RIGHT (L) read LEFT (R) read RIGHT (=) is LEFT equal to RIGHT? (S) swap LEFT and RIGHT (?) display this menu (Q)quit program Enter choice: 1)
Operating System: Windows 2000/XP
Microsoft Windows Visual C++ 6.0
I will email the .cpp files stipulated in assignment.**