#include<iostream>
#include<conio.h>
using namespace std;
class currency
{
int rupees;
int paisa;
public:
currency():rupees(0),paisa(0)
{
}
currency(int a):rupees(a),paisa(a)
{
}
currency(int r, int p):rupees(r),paisa(p)
{
}
void getamount()
{
cout<<"Enter rupees : ";cin>>rupees;
cout<<"Enter paisa : ";cin>>paisa;
}
void sum(currency c1, currency c2);
void display();
};
void currency::sum(currency c1, currency c2)
{
paisa=c1.paisa+c2.paisa;
rupees=0;
while(paisa>=100)
{
paisa=paisa-100;
rupees++;
}
rupees+=c1.rupees+c2.rupees;
}
void currency::display()
{
cout<<"Total Sum : \n";
cout<<"Rs. "<<rupees<<" and "<<paisa<<" Paisa";
}
int main()
{
currency c1(70);
currency c3;
currency c2(129,90);
//c1.getamount();
//c2.getamount();
c3.sum(c1,c2);
c3.display();
getch();
return(0);
}
No comments:
Post a Comment