GRP7

NAME 2: Li Jia Le
using namespace std; 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; };
 * 1) include

Rational ADD1(Rational R){ Rational Z; Z.num=num*R.den+R.num*den; Z.den=den*R.den; return Z; }; Rational MINUS1(Rational R){ Rational Z; Z.num=num*R.den-R.num*den; Z.den=den*R.den; return Z; }; Rational MULTIPLY1(Rational R){ Rational Z; Z.num=num*R.num; Z.den=den*R.den; return Z; }; Rational DIVIDE1(Rational R){ Rational Z; Z.num=num*R.den; Z.den=den*R.num; return Z; }; };

int main{

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

cout<<"A="; A.Display; cout<<endl; cout<<"B="; B.Display; cout<<endl; cout<<"A+B="; C=A.ADD1(B); C.Display; cout<<endl; cout<<"A-B="; C=A.MINUS1(B); C.Display; cout<<endl; cout<<"A*B="; C=A.MULTIPLY1(B); C.Display; cout<<endl; cout<<"A/B="; C=A.DIVIDE1(B); C.Display; cout<<endl; system("pause"); }//main