Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Bank Account assignment implement the three classes, Account, Checking, and

ID: 3767952 • Letter: C

Question

C++ Bank Account assignment

implement the three classes, Account, Checking, and Savings.

Implement a main program that reads commands from bank2.txt and carries out the commands using objects of these classes.

New Commands

Checking account initialBalance minimumBalance monthlyFee

Savings account initialBalance minimumBalance annualInterestRate

Deposit account amount

Withdraw account amount

Balance account

Close

Report

1.Implement a main program which reads commands from a file and carries them out.

2. Valid account numbers are 1-9. This requires the program to have an array of references to Account objects.

3. If the first word on any line contains a command other than the four listed above, an error message should be displayed and that line ignored.

4. The create command creates a new account object with the given account number and initial balance. If an account already exists with that number an error message should be displayed and the command ignored.

5. The Deposit and Withdraw commands perform the indicated operation on an existing account. If no account with that number has been created, an error message is displayed and the command ignored.

6. The Balance command displays the balance of the requested account. No change to the account occurs. If no account with that number has been created, an error message is displayed and the command ignored.

7. Test your program thoroughly. The instructor will use a different bank2.txt file to evaluate your program.

Absolute Requirements

? The Account class must be an abstract class with two pure virtual functions, closeMonth and accountString.

? The Savings and Checking classes must be subclasses of Account ? The bank must handle at least 10 accounts simultaneously with account numbers 1-9

? Do not duplicate the balance or ID fields in the subclasses

? The balance, withdrawal and deposit manipulation must use the methods in the base class Account.

? Each action must display appropriate messages indicating that the action was completed.

? The closeMonth and accountString functions must be called polymorphically. This means, they are called for each account without checking to see what kind of account it is being called on.

? An implication of the last point is that there will be a single array of Account objects, some of which are Checking accounts and some of which are Savings accounts.

bank2.txt

{

}

A working example of how this program should output.

File Opened Savings account number 1 created with an initial balance of $1000.01 Checking account number 2 created with an initial balance of $2000.02 Savings account number 3 created with an initial balance of $3000.03 Deposited $11.11 into account #1 current balance is $1011.12 Deposited $22.22 into accou current balance is $2022.24 Inualid Account Number4 Checking account number 4 created with an initial balance of $4000.04 Wit drew $8.1 from account #1 current balance is $1011.02 Current balance in account #2 is $2022.24 Withdrew $0.2 from account #2 current balance is $2022.04 Deposited $33.33 into accou current balance is $3033.36 Withdrew $0.4 from account #4 current balance is $3999.64 Unrecognized command Bad End of month processing complete Sav ings Account #1 has a balance of $1014.390067 Checking Account #2 has a balance of $2015.090000 Sav ings Account #3 has a balance of $3051.05 4600 Checking Account #4 has a balance of $3999.640000 Press any key to continue..

Explanation / Answer

#include <iostream.h>
#include <conio.h>

class details
{
char client_name[20];   

int acc_no;
char acc_type[20];
public:
void get_accinfo()
{
cout<<" Enter Customer Name :- ";
cin>>client_name;
cout<<"Enter Account Number :- ";
cin>>acc_no;
cout<<"Enter Account Type :- ";
cin>>acc_type;
}
void display_accinfo()
{
cout<<" Customer Name :- "<<client_name;
cout<<" Account Number :- "<<acc_no;
cout<<" Account Type :- "<<acc_type;
}
};

class cur_acct : public details
{
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 < 100)
{
penalty=(100-balance)/10;
balance=balance-penalty;
cout<<" Balance after deducting penalty : "<<balance;
}
elseif(withdraw > balance)
{
cout<<" take to permission for Bank Overdraft Facility ";
balance=balance+withdraw;
}
else
cout<<" After Withdrawl your Balance revels : "<<balance;
}
};

class sav_acct : public details
{
staticfloat savbal;
public:
void disp_savbal()
{
cout<<" Balance :- "<<savbal;
}
void deposit_savbal()
{
float deposit,interest;
cout<<" Enter amount to Deposit for the 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<<" take to 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 either S or C-> S for saving and C for current a/c OF 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 OPTION:-";
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<<" Invalid choice ,"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 OPTION:-";
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<<" Invalid choice ,"TRY AGAIN"";
}
}
}
end:
}
}