#include <iostream> #include "fraction.h" using namespace std; int main() { fraction f1(9,8); fraction f2(2,3); fraction result; cout << "The result starts off at "; result.print(); cout << endl; cout << "The product of "; f1.print(); cout << " and "; f2.print(); cout << " is "; result = f1.MultipliedBy(f2); result.print(); cout << endl; cout << "The quotient of "; f1.print(); cout << " and "; f2.print(); cout << " is "; result = f1.DividedBy(f2); result.print(); cout << endl; cout << "The sum of "; f1.print(); cout << " and "; f2.print(); cout << " is "; result = f1.AddedTo(f2); result.print(); cout << endl; cout << "The difference of "; f1.print(); cout << " and "; f2.print(); cout << " is "; result = f1.Subtract(f2); result.print(); cout << endl; if (f1.isEqualTo(f2)){ cout << "The two fractions are equal." << endl; } else { cout << "The two fractions are not equal." << endl; } const fraction f3(12, 8); const fraction f4(202, 303); result = f3.MultipliedBy(f4); cout << "The product of "; f3.print(); cout << " and "; f4.print(); cout << " is "; result.print(); cout << endl; system ("PAUSE");//exclude statement if not using Dev-C++ return 0; }

Write a fraction class whose objects will represent fractions. You should provide the following member functions:

1.

Two constructors, a default constructor which assigns the value 0 to the fraction, and a constructor that takes two parameters. The first parameter will represent the initial numerator of the fraction, and the second parameter will represent the initial denominator of the fraction.

2.

Arithmetic operations that add, subtract, multiply, and divide fractions. These should be implemented as value returning functions that return a fraction object. They should be named AddedTo, Subtract, MultipliedBy, and DividedBy.

3.

A boolean operation named isEqualTo that compares two fraction objects for equality.

4.

An output operation named print that displays the value of a fraction object on the screen in the form numerator/denominator.

This is the client program and instructions that I have been given. Here is what I got so far.

// Fraction class specification file class Fraction { public: void print(); Fraction MultipliedBy(Fraction) const; Fraction DividedBy(Fraction) const; Fraction AddedTo(Fraction) const; Fraction Subtract(Fraction) const; Fraction (); // default class constructor Fraction (int numerator, int denominator); // class constructor private: int numerator; int denominator; };

*** MOD EDIT: Added code tags. Please ***