Exercise: Banking accounts Banks offer various types of accounts, such as saving
ID: 654330 • Letter: E
Question
Exercise: Banking accounts
Banks offer various types of accounts, such as savings, checking, certificate of deposits, and money market, to attract customers as well as meet with their specific needs. Two of the most commonly used accounts are savings and checking. Each of these accounts has various options. For example, you may have a savings account that requires no minimum balance but has a lower interest rate. Similarly, you may have a checking account that limits the number of checks you may write. Another type of account that is used to save money for the long term is certificate of deposit (CD).
In this programming exercise, you use abstract classes and pure virtual functions to design classes to manipulate various types of accounts. For simplicity, assume that the bank offers three types of accounts: savings, checking, and certificate of deposit, as described next.
Savings accounts: Suppose that the bank offers two types of savings accounts: one that has no minimum balance and a lower interest rate and another that requires a minimum balance and has a higher interest rate.
Checking accounts: Suppose that the bank offers three types of checking minimum balance, and no interest; another with no monthly service charge, a minimum balance requirement, unlimited check writing and lower interest; and a third with no monthly service charge, a higher minimum requirement, a higher interest rate, and unlimited check writing.
Certificate of deposit (CD): In an account of this type, money is left for some time, and these accounts draw higher interest rates than savings or checking accounts. Suppose that you purchase a CD for six months. Then we say that the CD will mature in six months. Penalty for early withdrawal is stiff.
The figure, on next page, shows the inheritance hierarchy of these bank accounts. Note that the classes bankAccount and checkingAccount are abstract. That is, we cannot instantiate objects of these classes. The other classes in the next figure are not abstract. Next we describe each of the classes:
bankAccount: Every bank account has an account number, the name of the owner, and a balance. Therefore, instance variables such as name, accountNumber, and balance should be declared in the abstract class bankAccount. Some operations common to all types of accounts are retrieve account owner
Explanation / Answer
class bankAccount
{
public:
int getAccountNumber();
double getBalance();
string getName();
void setName(string name);
void withdraw(double balance);
void deposit(double balance);
abstract void createMonthlyStatement();
private:
int accountNumber;
string name;
double balance;
}
class savingsAccount: public bankAccount
{
public:
void writeCheck(double);
}
class checkingAccount: public banckAccount
{
public:
void writeCheck( double balance);
}
class ServiceChecking: public checkingAccount
{
public:
double getServiceChargeAccount();
void setServiceChargeAccount();
double getServiceChargeChecks();
void setServiceChargeChecks();
int getNumberOfChecksWritten();
void setNumberOfChecksWritten(int );
void writeCheck();
private:
double ACCOUNT_SERVICE_CHARGE = 10.00;
int MAXIMUM_NUM_OF_CHECKS = 5;
protected:
double serviceChargeAccount;
double serviceChargeCheck;
int numberOfChecksWritten;
}
class noServiceChecking: public checkingAccount
{
public:
double getMinimumBalance();
void getMinimumBalance(double);
void writeCheck(double);
void withdraw(double);
private:
double MIN_BALANCE = 1000.00;
double INTEREST_RATE = 0.02;
protected:
double minimumBalance;
double interestRate;
}
class highInterestChecking: public noServiceChecking
{
public:
double getInterestRate();
void setInterestRate(double);
private:
double INTEREST_RATE=0.05;
double MIN_BALANCE=5000.00;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.