Question: 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
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 $20 penalty if an attempt is made to withdraw more money than is available in the account. Test your Account class by using the following main function. int main() { Account my_account(100); // Set up my account with $100 my_account.deposit(50); my_account.withdraw(175); // Penalty of $20 will apply my_account.withdraw(25);
cout << "Account balance: " << my_account.get_balance() << " "; my_account.withdraw(my_account.get_balance()); // withdraw all cout << "Account balance: " << my_account.get_balance() << " "; return 0; }
Output
Account balance: 120 Account balance: 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
