Samuel+Tan

Type in the content of your page here. code using namespace std;
 * 1) include

class Rational{ protected: int num, den;

public: Rational {num=0;den=0;}; Rational(int a, int b){num=a; den=b;}; ~Rational {}; void display{cout<<num<<" / "<<den;}; void Set_num(int n){num = n;}; void Set_den(int d){den = d;}; void Set_num2(int n2){num = n2;}; void Set_den2(int d2){den = d2;}; Rational add(Rational tmp){ Rational R;              R.num = num*tmp.den + tmp.num*den; R.den = den*tmp.den; return R;     }; Rational minus(Rational tmp){ Rational R;              R.num = num*tmp.den - tmp.num*den; R.den = den*tmp.den; return R;     }; Rational multiply(Rational tmp){ Rational R;              R.num = num*tmp.num; R.den = den*tmp.den; return R;     }; Rational divide(Rational tmp){ Rational R;              R.num = num*tmp.den; R.den = den*tmp.num; return R;     }; };

int a, b, c, d, x; int main{

x:

Rational Fraction1(a,b), Fraction2(c,d), Fraction3; Fraction1.add(Fraction2); cout<<"Enter numerator for number 1: "; cin>> a;   cout<<"\n"; cout<<"a = "<> b;   cout<<"\n"; cout<<"b = "<> c;   cout<<"\n"; cout<<"c = "<> d;   cout<<"d = "<<d; cout<<"\n\n";

cout<<"\n"; Fraction1.Set_num(a); cout<<"\n"; Fraction1.Set_den(b); cout<<"\n"; Fraction2.Set_num2(c); cout<<"\n"; Fraction2.Set_den2(d);

cout<<"Number 1 is: "; Fraction1.display; cout<<"\n"; cout<<"Number 2 is: "; Fraction2.display; cout<<"\n\n"; cout<<"Number 1 + Number 2 is: "; Fraction3 = Fraction1.add(Fraction2); //add number 1 and number 2 Fraction3.display; cout<<"\n\n";

cout<<"Number 1 - Number 2 is: "; Fraction3 = Fraction1.minus(Fraction2); //minus number 1 and number 2 Fraction3.display; cout<<"\n\n";

cout<<"Number 1 x Number 2 is: "; Fraction3 = Fraction1.multiply(Fraction2); //multiply number 1 and number 2 Fraction3.display; cout<<"\n\n";

cout<<"Number 1 / Number 2 is: "; Fraction3 = Fraction1.divide(Fraction2); //multiply number 1 and number 2 Fraction3.display; cout<<"\n\n\n\n"; cout<<"\n";

goto x;   system ("pause"); return 0; }

code