Banks offer various types of accounts such as savings checki
Banks offer various types of accounts, such as savings, checking, certificate of deposits, and money market, to attract customers as well as meet 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 accounts: one with a monthly service charge, limited check writing, no
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. The penalty for early withdrawal is stiff.
Note that the classes bankAccount and checkingAccount are abstract. That is, we cannot instantiate objects of these classes. The other classes in Figure 12-25 are not abstract. 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’s name, account number, and account balance; make deposits;
withdraw money; and create monthly statements. 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.
serviceChargeChecking: A service charge checking account is a checking account. Therefore, it inherits all the 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.
bank Account checking Count certificateoff Deposit saving SAccount high Interestsavings service chargechecking noservicechargechecking high InterestSolution
#include <iostream.h>
#include <conio.h>
class account
{
char cust_name[20];
int acc_no;
char acc_type[20];
public:
void get_accinfo()
{
cout<<\"\ \ Enter Customer Name :- \";
cin>>cust_name;
cout<<\"Enter Account Number :- \";
cin>>acc_no;
cout<<\"Enter Account Type :- \";
cin>>acc_type;
}
void display_accinfo()
{
cout<<\"\ \ Customer Name :- \"<<cust_name;
cout<<\"\ Account Number :- \"<<acc_no;
cout<<\"\ Account Type :- \"<<acc_type;
}
};
class cur_acct : public account
{
staticfloat balance;
public:
void disp_currbal()
{
cout<<\"\ Balance :- \"<<balance;
}
void deposit_currbal()
{
float deposit;
cout<<\"\ Enter amount to Deposit :- \";
cin>>deposit;
balance = balance + deposit;
}
void withdraw_currbal()
{
float penalty,withdraw;
cout<<\"\ \ Balance :- \"<<balance;
cout<<\"\ Enter amount to be withdraw :-\";
cin>>withdraw;
balance=balance-withdraw;
if(balance < 500)
{
penalty=(500-balance)/10;
balance=balance-penalty;
cout<<\"\ Balance after deducting penalty : \"<<balance;
}
elseif(withdraw > balance)
{
cout<<\"\ \ You have to take permission for Bank Overdraft Facility\ \";
balance=balance+withdraw;
}
else
cout<<\"\ After Withdrawl your Balance revels : \"<<balance;
}
};
class sav_acct : public account
{
staticfloat savbal;
public:
void disp_savbal()
{
cout<<\"\ Balance :- \"<<savbal;
}
void deposit_savbal()
{
float deposit,interest;
cout<<\"\ Enter amount to Deposit :- \";
cin>>deposit;
savbal = savbal + deposit;
interest=(savbal*2)/100;
savbal=savbal+interest;
}
void withdraw_savbal()
{
float withdraw;
cout<<\"\ Balance :- \"<<savbal;
cout<<\"\ Enter amount to be withdraw :-\";
cin>>withdraw;
savbal=savbal-withdraw;
if(withdraw > savbal)
{
cout<<\"\ \ You have to take permission for Bank Overdraft Facility\ \";
savbal=savbal+withdraw;
}
else
cout<<\"\ After Withdrawl your Balance revels : \"<<savbal;
}
};
float cur_acct :: balance;
float sav_acct :: savbal;
void main()
{
clrscr();
cur_acct c1;
sav_acct s1;
cout<<\"\ Enter S for saving customer and C for current a/c customer\ \ \";
char type;
cin>>type;
int choice;
if(type==\'s\' || type==\'S\')
{
s1.get_accinfo();
while(1)
{
clrscr();
cout<<\"\ Choose Your Choice\ \";
cout<<\"1) Deposit\ \";
cout<<\"2) Withdraw\ \";
cout<<\"3) Display Balance\ \";
cout<<\"4) Display with full Details\ \";
cout<<\"5) Exit\ \";
cout<<\"6) Choose Your choice:-\";
cin>>choice;
switch(choice)
{
case 1 : s1.deposit_savbal();
getch();
break;
case 2 : s1.withdraw_savbal();
getch();
break;
case 3 : s1.disp_savbal();
getch();
break;
case 4 : s1.display_accinfo();
s1.disp_savbal();
getch();
break;
case 5 : goto end;
default: cout<<\"\ \ Entered choice is invalid,\\\"TRY AGAIN\\\"\";
}
}
}
else
{
{
c1.get_accinfo();
while(1)
{
cout<<\"\ Choose Your Choice\ \";
cout<<\"1) Deposit\ \";
cout<<\"2) Withdraw\ \";
cout<<\"3) Display Balance\ \";
cout<<\"4) Display with full Details\ \";
cout<<\"5) Exit\ \";
cout<<\"6) Choose Your choice:-\";
cin>>choice;
switch(choice)
{
case 1 : c1.deposit_currbal();
getch();
break;
case 2 : c1.withdraw_currbal();
getch();
break;
case 3 : c1.disp_currbal();
getch();
break;
case 4 : c1.display_accinfo();
c1.disp_currbal();
getch();
break;
case 5 : goto end;
default: cout<<\"\ \ Entered choice is invalid,\\\"TRY AGAIN\\\"\";
}
}
}
end:
}
}




