#include<iostream.h>
#include<conio.h>

class currency
{
  long int rup;
  int paise;

  public:
  void getcurrency()
  {
    cout<<endl<<"Enter currency in rupees and paise: ";
    cin>>rup>>paise;
  }

  currency operator+(currency &c)
  {
    currency temp;
    temp.rup=rup+c.rup;
    temp.paise=paise+c.paise;
    return temp;
  }

  currency operator-(currency &c)
  {
    currency temp;
    temp.rup=rup-c.rup;
    temp.paise=paise-c.paise;
    return temp;
  }

  void display()
  {
    cout<<rup<<" rupees and "<<paise<<" paise";
  }
};//end of class

int main()
{
clrscr();
currency c1;
c1.getcurrency();
currency c2;
c2.getcurrency();
cout<<endl<<"Currency1 is: ";
c1.display();
cout<<endl<<"Currency2 is: ";
c2.display();
currency c3=c1+c2;
cout<<endl<<"Currency1 + Currency2 is: ";
c3.display();
currency c4=c1-c2;
cout<<endl<<"Currency1 - Currency2 is: ";
c4.display();
getch();
return 0;
}

Post a Comment

Previous Post Next Post