Class Description
In this lab you will create a complete class to handle fractions. The fraction class will have data members to hold the numerator and denominator, both of which will be integers.
Your class must have the following member functions:
- Print a fraction to the screen using a function called Output().
- Compute the reciprocal of a fraction using a function called Reciprocal().
- A default constructor that initializes the fraction to 1/1.
- A second constructor that allows the user to initialize the numerator and denominator using the syntax Fraction frac(numerator, denominator). This constructor must also check that the denominator is not zero.
You will create a source file lab4.cpp to contain your main() function, but the class declaration and definitions must be in the files Fraction.h and Fraction.cpp, respectively.
Here is skeleton code for lab4.cpp:
#include <iostream> #include "Fraction.h" using namespace std; int main() { // Create 3 fractions: // - Read the first fraction from the keyboard using cin. // Find the reciprocal of this fraction and print it to the screen. // - The second fraction will be created with default values. You // should also print this to the screen. // - Attempt to create a fraction with a denominator of zero, which // should print an error return 0; }