#include <iostream>
#include <string>
using namespace std;
class bMoney{
private:
long double money;
public:
bMoney();
bMoney(char s[]);
void madd(bMoney m1, bMoney m2);
void getmoney();
void putmoney();
};
bMoney::bMoney(){
}
bMoney::bMoney(char s[]){
//convert a money string entered as input into a long double
this->money=stold(s);
}
void bMoney::madd(bMoney m1, bMoney m2){
long double sum=m1.money+m2.money;
cout<<"Sum = "<<sum<<"\n";
}
void bMoney::getmoney(){
cout<<"Enter money: ";
cin>>money;
}
void bMoney::putmoney(){
cout<<"Money: "<<money<<"\n";
}
int main()
{
bMoney b1,b2;
b1.getmoney();
b2.getmoney();
b1.putmoney();
b2.putmoney();
b1.madd(b1,b2);
int k;
cin>>k;
return 0;
}
Comments
Leave a comment