0

I have an assignment of the following.

Create a class named Fractions having two integer data members named for a fraction’s numerator and denominator. The Class’s default constructor should provide both data members with default values of 1 if no explicit user initialization is provided. The constructor must also prohibit a 0 denominator value. Additionally, provide member functions for displaying an object’s data values. Also provide the class with overloaded operators that are capable of adding, subtracting, multiplying and dividing two Fraction objects according to the following formulas:

Sum of two fractions: a/b + c/d = ad + cb
--------
bd
Difference of two fractions: a/b – c/d = ad – cb
______
bd

Product of two fractions a/b X c/d = ac
---
bd
Division of two fractions: a/b / c/d = ad
---
bc


To be fairly honest with you, I don't even know where to begin on this. I will toy with it and post what I have and hope you guys can help me.

Thank you

2
Contributors
2
Replies
3
Views
11 Years
Discussion Span
Last Post by rgrwalker
0
class Fractions
{

public:

     //class constructor
     Fractions( );

     //overloaded operators
     Fraction operator+(const Fraction &rhs);
     Fraction operator-(const Fraction &rhs);
     Fraction operator/(const Fraction &rhs);
     Fraction operator*(const Fraction &rhs);

     //other 
     void print( );

private:

     int numerator;
     int denominator;
}

This is about all the help I can give ye' for now.. Above is an example class that should get you started.. all you have to do is write the functions. :cool:

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.