Bank class must have the listed 2 constructors Default const
Solution
#include<iostream>
#include<string>
using namespace std;
class Bank
{
string fname;
string lname;
double balance;
public:
Bank()
{
fname = \"\" ;
lname = \"\";
balance = 0;
}
Bank(string f, string l,double bal)
{
fname = f;
lname = l;
balance= bal;
}
string getFname()
{
return fname;
}
string getLname()
{
return lname;
}
double getbal()
{
return balance;
}
void setFname(string f)
{
fname = f;
}
void setLname(string l)
{
lname = l;
}
void setbal(double bal)
{
balance = bal;
}
void add_amt(double amt)
{
balance+=amt;
}
void withdraw_amt(double amt)
{
if( balance <= 0 )
{
cout<<\"not enough funds \"<<endl;
return;
}
balance-=amt;
}
void print()
{
cout<<\"Firstname Lastname balance\"<<endl;
cout<<fname<<\"\\t\"<<lname<<\"\\t\"<<balance<<endl;
}
};
int main()
{
Bank bnk1;
Bank bnk2(\"John\",\"Doe\",12.7);
//Testing set methods for class
bnk1.setFname(\"John\");
bnk1.setLname(\"Doe\");
bnk1.setbal(15.8);
//Testing get methods for class
cout<<\"Firstname Lastname balance\"<<endl;
cout<<bnk1.getFname()<<\"\\t\"<<bnk1.getLname()<<\"\\t\"<<bnk1.getbal()<<endl;
//testing print method of class
bnk2.print();
//testing add amount
bnk2.add_amt(12);
bnk2.print();
//testing withdraw
bnk2.withdraw_amt(12);
bnk2.print();
bnk2.withdraw_amt(12.7);
bnk2.print();
bnk2.withdraw_amt(12.7);
bnk2.print();
}

