Yong+Keat

code format="cpp" /* Comments: Your solution is not correct. Please take a look at the approach at which the others are taking for guidance.

*/

#include using namespace std;

class findGCF{ protected: int num2, den2; public:

findGCF{num2=0; den2=1;}; //Default Constructor findGCF(int n2, int d2){num2 = n2; den2 = d2;}; //Constructor ~findGCF{}; //Destructor

void Display{ cout << num2 << "/" << den2; }; //Public member function to display Fraction

//Setter Functions void Set_num(int n2){num2 = n2; }; void Set_den(int d2){den2 = d2; };

int rand {

int t, b, dive,r,divs;

if (num2 > den2) {             dive = num2; divs = den2; } else {           dive = den2; divs = num2; }

do{ r = dive % divs;

if (r!=0) {              dive=divs; divs=r; } }while(r!=0); //loop until remainder = 0;

return(divs);

}

int t {return(num2/rand);}; int b {return(den2/rand);};

};

class Rational{ protected: int num, den; public: Rational{num=0; den=1;}; //Default Constructor Rational(int n, int d){num = n; den = d;}; //Constructor ~Rational{}; //Destructor

//Setter Functions void Set_num(int n){num = n; }; void Set_den(int d){den = d; };

int Add1 {return(num*5+den*3);}; int Add2 {return(den*5);}; int Sub1 {return(den*3-num*5);}; int Sub2 {return(den*5);}; int Mup1 {return(3*num);}; int Mup2 {return(den*5);}; int Div1 {return(3*den);}; int Div2 {return(num*5);}; int rand {return(Div1*Div2);};

void Display{

findGCF Add(Add1,Add2); findGCF Sub(Sub1,Sub2); findGCF Mup(Mup1,Mup2); findGCF Div(Div1,Div2);

cout << endl << "Results: " << endl;

cout << "Addition: " << Add.t << "/" << Add.b; cout << endl << "Subtraction: " << Sub.t << "/" << Sub.b; cout << endl << "Multiplication: " << Mup.t << "/" << Mup.b; cout << endl << "Division; " << Div.t << "/" << Div.b;

};

//Public member function to display Fraction

};//Rational

int main { int value,int1,int2;

cout << "1st number: 3/5" << endl; cout << "Input 2nd number (numerator demoninator): "; cin >> int1 >> int2;

Rational frac(int1,int2); //function after input frac.Display;

cout << endl << endl;

system("pause"); }

code