GRP6

NAME 2:Teo Jim Yang

 * ADD.cpp

using namespace std;
 * include

class Rational{ protected: int num; int den; public: Rational{num = 0; den = 1;}; Rational(int x, int y){ num = x; den = y; }; ~Rational{}; void Display{ cout << num << "/" << den; };

Rational SUB1(Rational R){ Rational Z; Z.num = num * R.den + R.num * den; Z.den = den * R.den; return Z; }; };

int main{

Rational A(3,2); Rational B(2,3); Rational C;

A.Display; cout << endl; B.Display; cout << endl;

C = A.SUB1(B); C.Display; cout << endl;

}**


 * MINUS.cpp

using namespace std;
 * include

class Rational{ protected: int num; int den; public: Rational{num = 0; den = 1;}; Rational(int x, int y){ num = x; den = y; }; ~Rational{}; void Display{ cout << num << "/" << den; };

Rational MINUS(Rational R){ Rational Z; Z.num = num*R.den - R.num*den; Z.den = den*R.den; return Z; }; };

int main{

Rational A(3,2); Rational B(2,3); Rational C;

A.Display; cout << endl; B.Display; cout << endl;

C = A.MINUS(B); C.Display; cout << endl;

}**


 * MULTIPLY.cpp

using namespace std;
 * include

class Rational{ protected: int num; int den; public: Rational{num = 0; den = 1;}; Rational(int x, int y){ num = x; den = y; }; ~Rational{}; void Display{ cout << num << "/" << den; };

Rational MULTIPLY(Rational R){ Rational Z; Z.num = num * R.num; Z.den = den * R.den; return Z; }; };

int main{

Rational A(5,2); Rational B(2,3); Rational C;

A.Display; cout << endl; B.Display; cout << endl;

C = A.MULTIPLY(B); C.Display; cout << endl;

}**


 * **DIVIDE.cpp**

using namespace std;
 * include

class Rational{ protected: int num; int den; public: Rational{num = 0; den = 1;}; Rational(int x, int y){ num = x; den = y; }; ~Rational{}; void Display{ cout << num << "/" << den; };

Rational DIVIDE(Rational R){ Rational Z; Z.num = num * R.den; Z.den = den * R.num; return Z; }; };

int main{

Rational A(3,2); Rational B(2,3); Rational C;

A.Display; cout << endl; B.Display; cout << endl;

C = A.DIVIDE(B); C.Display; cout << endl;

}**