4. (Class 20 Points) Create a class called Account that represents customers\' b
ID: 3704795 • Letter: 4
Question
4. (Class 20 Points) Create a class called Account that represents customers' bank accounts. In this class, the balance member of type int represents the account balance. Please implement the following member functions: (5 points) Member function creditBalance should add an amount to the current balance. (5 points) Member function debitBalance should withdraw money from the Account and ensure that the debit amount does not exceed the Account's balance. If it does, the balance should be left unchanged and the function should print a message "Debit amount exceeded account balance." (5 points) Member function getBalance should return the current balance. .(5 points) Member function setBalance should set balance to an initial balance. class Account public: Account int void setBalance( int ) int getBalance) int debitBalance ( int ); int creditBalance( int private: int balance; // bank account balance nameExplanation / Answer
class Account { public: Account(int); void setBalance(int); int getBalance(); int debitBalance(int); int creditBalance(int); private: int balance; }; Account::Account(int bal) { balance = bal; } void Account::setBalance(int amount) { balance = amount; } int Account::getBalance() { return balance; } int Account::debitBalance(int amount) { if(balanceRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.