Ang+Ray+Yan

class rational { protected: int num, den;

void reduce(rational e){ int a = abs((double)e.num)= 2; i--) if(final.num%i == 0 && final.den%i==0){ final.num=(final.num/i); final.den=(final.den/i); break; } if(neg == -1 && neg2 == -1) neg = neg2 = 1; if(neg2 == -1 && neg == 1){ neg = -1; neg2 = 1;} final.num *= neg; final.den *= neg2; display(final); }

public:

rational{}; rational(int a, int b){num = a; den = b;}; ~rational{}; void display(rational g){ if(g.den!=1)printf("%d/%d\n", g.num, g.den); else printf("%d\n", g.num); } int setr(int a, int b){ num = a; den = b;}

//Did Add but Implementation do not fullfill question requirements, did not assign the result of the operation to the left hand side of the equation. void add(rational h){ rational final(num*h.den+h.num*den, h.den*den); reduce(final); }

//Did subtract but Implementation do not fullfill question requirements, did not assign the result of the operation to the left hand side of the equation. void minus(rational z){ rational final(num*z.den-z.num*den,z.den*den); reduce(final); }

//Did divide but Implementation do not fullfill question requirements, did not assign the result of the operation to the left hand side of the equation. void divide(rational c){ c.den ^= c.num; c.num ^= c.den; c.den ^= c.num; multiply(c); }

//Did multiply but Implementation do not fullfill question requirements, did not assign the result of the operation to the left hand side of the equation. void multiply(rational d){ rational e; e.num = num*d.num; e.den = den*d.den; reduce(e); }

};