Define currency class which contains rupees and paisa as data members. Write a friend function named AddCurrency( )which add 2 different Currency objects and returns a Currencyobject. Write parameterized constructor to initialize the values and use appropriate functions to get the details from the user and display it.
#include<iostream>
using namespace
std;
class currency
{
int r;
int p;
public:
currency()
{
r=p=0;
}
currency(int x,int y)
{
r=x;
p=y;
}
void getcurrency()
{
cout<<"\n"<<r<<" Rs."<<p <<" Paise";
}
friend currency addcurrency(currency,currency);
};
currency addcurrency(currency c1,currency c2)
{
currency
t1;
t1.r=c1.r+c2.r;
t1.p=c1.p+c2.p;
if(t1.p>=100)
{
t1.r++;
t1.p-=100;
}
return(t1);
}
void main()
{
currency
obj1(5,50),obj2(1,60),obj3;
obj1.getcurrency();
obj2.getcurrency();
obj3=addcurrency(obj1,obj2);
obj3.getcurrency();
}