Please help me on c++ using code blocks Banks offer various types of accounts, s
ID: 3766669 • Letter: P
Question
Please help me on c++ using code blocks 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 owners name, account number, and account balance; make deposits; withdraw money; and create monthly statement. So include functions to implement these operations. Some of these functions will be pure virtual. checkingAccount: A checking account is a bank account. Therefore, it inherits all the properties of a bank account. Because one of the objectives of a checking account is to be able to write checks, include the pure virtual function writeCheck to write a check. http://www.m5zn.com/newuploads/2015/04/14/png//16037d977673d59.png properties of a checking account. For simplicity, assume that this type of account does not pay any interest, allows the account holder to write a limited number of checks each month, and does not require any minimum balance. Include appropriate named constants, instance variables, and functions in this class. noServiceChargeChecking: A checking account with no monthly service charge is a checking account. Therefore, it inherits all the properties of a checking account. Furthermore, this type of account pays interest, allows the account holder to write checks, and requires a minimum balance. highInterestChecking: A checking account with high interest is a checking account with no monthly service charge. Therefore, it inherits all the properties of a no service charge checking account. Furthermore, this type of account pays higher interest and requires a higher minimum balance than the no service charge checking account. savingsAccount: A savings account is a bank account. Therefore, it inherits all the properties of a bank account. Furthermore, a savings account also pays interest. highInterestSavings: A high-interest savings account is a savings account. Therefore, it inherits all the properties of a savings account. It also requires a minimum balance. certificateOfDeposit: A certificate of deposit account is a bank account. Therefore, it inherits all the properties of a bank account. In addition, it has instance variables to store the number of CD maturity months, interest rate, and the current CD month. Write the definitions of the classes described in this programming exercise and a program to test your classes. http://www.m5zn.com/newuploads/2015/04/14/png//d237c73822e5bb7.png http://www.m5zn.com/newuploads/2015/04/14/png//64378790da1ac6e.png testDriver.cpp #include #include #include "bankAccount.h" #include "savingsAccount.h" #include "highInterestSavings.h" #include "noServiceChargeChecking.h" #include "serviceChargeChecking.h" #include "highInterestChecking.h" #include "certificateOfDeposit.h" #include "checkingAccount.h" using namespace std; int main() { bankAccount *accountsList[6]; accountsList[0] = new savingsAccount("Ahmed", 10200, 2500); accountsList[1] = new highInterestSavings("Fatima", 10210, 2000); accountsList[2] = new noServiceChargeChecking("Salem", 20100, 3500); accountsList[3] = new serviceChargeChecking("Ravi", 30100, 1800); accountsList[4] = new highInterestChecking("Judy", 20200, 6000); accountsList[5] = new certificateOfDeposit("Hamed", 51001, 18000, 0.075, 18); cout << "January: -------------" << endl; for (int i = 0; i < 6; i++) { accountsList[i]->createMonthlyStatement(); accountsList[i]->print(); cout << endl; } cout << " February: -------------" << endl; for (int i = 0; i < 6; i++) { accountsList[i]->createMonthlyStatement(); accountsList[i]->print(); cout << endl; } for (int i = 0; i < 6; i++) { accountsList[i]->withdraw(500); } cout << " March: -------------" << endl; for (int i = 0; i < 6; i++) { accountsList[i]->createMonthlyStatement(); accountsList[i]->print(); cout << endl; } return 0; }
Explanation / Answer
Answer:
Note: I implemented the classes. Include the .h files and the tester methods to compile the code
Answer:
C++ code:
//name of the class
class bankAccount
{
public:
int acc_number1;
String name1;
float balance1;
void deposit1()=0;
void withdraw1()=0;
void create_ monthly_ statement1()=0;
void print1()=0;
}
//child class1
class savingsAccount:public bankAccount
{
savingsaccount(string n1 ,int acc_no1,flaot b1)
{
acc_number1=acc_no1;
strcpy(name1,n1);
balance1=b1;
}
virtual void create_ monthly_ statement1()
{
}
//child class2
class highInterestSavings:public savingsAccount
{
public:
highInterestSavings(string n1,int acc_no1,flaot b1)
{
acc_number1=acc_no1;
strcpy(name1,n1);
balance1=b1;
}
}
//child class3
class checkingAccount:public bankAccount
{
int num_checks1;
float min_bal1;
public:
void writeCheck1()=0;
}
//child class4
class noServiceChargeChecking: public checkingAccount
{
float interest1;
public:
noServiceChargeChecking(string n1 ,int acc_no1,flaot b1)
{
acc_number1=acc_no1;
strcpy(name1,n1);
balance1=b1;
}
writeCheck1()
{
}
}
//child class5
class highInterestChecking:public noServiceChargeChecking
{
public:
highInterestChecking(string n1 ,int acc_no1,flaot b1)
{
acc_number1=acc_no1;
strcpy(name1,n1);
balance1=b1;
}
}
//child class6
class serviceChargeChecking : public checkingAccount
{
public:
serviceChargeChecking (string n1 ,int acc_no1,flaot b1)
{
acc_number1=acc_no1;
strcpy(name1,n1);
balance1=b1;
}
}
//child class7
class certificateOfDeposit:public bankAccount
{
int num_ of_ CDmaturity_ months1;
float interest _rate1;
public:
certificateOfDeposit(String n1,int a1,float b1,float r1,int n1)
{
strcpy(name1,n1);
acc_number1=a1;
balance1=b1;
interest _rate1=r1;
num_ of_ CD maturity_ months1=n1;
}
}