C++ p5.4 Implement a class Account. An account has a balance, functions to add a
ID: 3767125 • Letter: C
Question
C++
p5.4 Implement a class Account. An account has a balance, functions to add and withdraw money, and a function to query the current balance. Charge a $5 penalty if an attempt is made to withdraw more money than is in the account. class Account
{
public:
Account(); Account(double bal); double get_balance(); void print_balance(); void withdraw(double); void deposit(double);
private:
const int fee=5;
};
Account::Account()
{ balance = 0; }
Account::Account(double bal)
{ balance = bal; }
Account::get_balance()
{ return balance; }
Account::print_balance()
{ cout<<balance;}
Account::withdraw(double w)
{if(w>balance)
{ balance-=fee; }
else { balance-=w; }}
Account::deposit(double d)
{ balance+=d; }
Please correct my work in that problem, then this is the one I need help with writing:
P5.6 Implement a class Bank. This class has two objects, checking and savings, of the type Account that was developed in P5.4. Implement four member functions:
void deposit(double amount, string account)
void withdraw(double amount, string account)
void transfer(double amount, string account)
void print_balances()
Here the account string is “S” or “C”. For the deposit or withdrawal, it indicates which account is affected. For a transfer it indicates the account from which the money is taken The money is automatically transferred to the other account.
Explanation / Answer
_______________________________
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.