Shao+Yun

WHEE code format="cpp" //By Tan Shao Yun 3S228 /////////////////////// using namespace std;
 * 1) include

class Rational{ private: //Variables int mer, nom;

public: //Constructor Rational(int n, int d){ mer=n; nom=d; };   //Destructor ~Rational{/*BOOM*/};

//To rejoin the answers into a fraction int MakeFrac(int frac,int tion){ mer=frac; nom=tion; };   //To display any fraction int Display{ cout<<mer<<"/"<<nom<<endl; return 0; };   /*EQUATIONS*/ Rational MULTIPLY(Rational fra){ int frac, tion; frac=mer*fra.mer; tion=nom*fra.nom; Rational means(frac,tion); means.SIMPLE; return(means); };   Rational DIVIDE(Rational fra){ int frac, tion; frac=mer*fra.nom; tion=nom*fra.mer; Rational means(frac,tion); means.SIMPLE; return(means); };   Rational ADD(Rational fra){ int frac, tion; frac=(mer*fra.nom)+(fra.mer*nom); tion=nom*fra.nom; Rational means(frac,tion); means.SIMPLE; return(means); };   Rational MINUS(Rational fra){ int frac, tion; frac=(mer*fra.nom)-(fra.mer*nom); tion=nom*fra.nom; Rational means(frac,tion); means.SIMPLE; return(means); };

protected: Rational SIMPLE{ int top=99; while(top>1){ if(mer%top==0&&nom%top==0){ mer/=top; nom/=top; }			top--; }		Rational means(mer,nom); return(means); }; };

int main{ int choice; Rational R1(2,3), R2(1,4), R3(0,1); cout<<"=OPTIONS============"<>choice; if(choice==1){ R3=R1.ADD(R2); R3.Display; system("PAUSE"); exit(1); }else if(choice==2){ R3=R1.MINUS(R2); R3.Display; system("PAUSE"); exit(1); }else if(choice==3){ R3=R1.MULTIPLY(R2); R3.Display; system("PAUSE"); exit(1); }else if(choice==4){ R3=R1.MINUS(R2); R3.Display; system("PAUSE"); exit(1); }else{ exit(1); }   return 0; } code