Write your question here.
Create a class called Account that a bank might use to represent customers' bank accounts. Your class should
include one data member of type int to represent the account balance. Your class should provide a constructor
that receives an initial balance and uses it to initialize the data member. The constructor should validate the
initial balance to ensure that it is greater than or equal to 0. If not, the balance should be set to 0 and the
constructor should display an error message, indicating that the initial balance was invalid. The class should
provide three member functions. Member function credit should add an amount to the current balance.
Member function debit should withdraw money from the Account and should 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 indicating "Debit amount exceeded account balance." Member function getBalance
should return the current balance. Create a program that creates two Account objects and tests the member
functions of class Account.
[code]
#include <iostream>
using std::cout;
using std::endl;
#include "Account.h" //include definition of Class Account
Account::Account(){} //default constructer
Account::Account(int balnce)
{
setBalance(balnce);
}// end constructer
displayMsg() looks a bit crazy, try moving the cout statements into their respective members [accDebit()/acCredit()] so that it logs the transaction when it happens.
here's an example main loop so you can get the idea...