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

Your program should also be able to deposit money, withdraw money, and check bal

ID: 648826 • Letter: Y

Question

Your program should also be able to deposit money, withdraw money, and check balance on a specific bank account. See below for more details.

(I) Your program should have the following functionalities:

Show a menu to the user to

Add a bank account

Print existing bank accounts

Search existing bank accounts based on the account number

Exit the program

Then, get the choice of the user and perform an appropriate action.

     

If the user selects searching for an existing account, if the account is found, then show the user another menu to

Deposit money to the account

Withdraw money from the account (if there are enough funds!)

Check the balance on the account

Exit to the main menu

Then, get the choice of the user and perform an appropriate action on the account. If the account is not found, then show a message to the user.

(II) Major Data Structures in your program:

Create a C++ class called BankAccount to hold following data:

Account holder

Explanation / Answer

#include<iostream.h>
#include<string.h>
#include<process.h>

class accountDetails
{
   public:
       char *custname;
       int custage;
       char custbranch[50];
       char custcity[40];
       void getBankdetails()
       {
           custname=new char[20];
           cout<<endl<<endl<<"**********Customer Details*********** "<<endl;
           cout<<" -------- ------- "<<endl;
           cout<<"Enter Name: ";
           cin>>custname;
           cout<<"Enter Age: ";
           cin>>custage;
           cout<<"Enter Branch: ";
           cin>>custbranch;
           cout<<"Enter City: ";
           cin>>custcity;
           cout<<"______________________________________"<<endl<<endl;
       }
};
class bankAccount
{
   public:
       static int accnumber;
       long accbalance;
       accountDetails d;
       void getBankdata();
       bankAccount transfermoneyBank(bankAccount);
       void depositBank();
       void withdrawalBank();
       void newaccountBank();
       void viewaccdetailsBank();
};
int bankAccount::accnumber=0;
void main()
{
   char ch1;
   static int i1=0;
   bank *a1[10];
   int x1,amt1,k1,j1;
   clrscr();
   do
   {
   cout<<endl<<endl<<"************MENU************"<<endl;
   cout<<" ---- "<<endl;
   cout<<"1.Create new account 2.Deposit 3.Withdraw 4.Transfer credits 5.View account details ";
   cout<<"Enter choice no.: ";
   cin>>x1;
   switch(x1)
   {
       case 1:
       {
           i1++;
           a[i1]=new bank;
           a[i1]->newaccount();
           break;
       }
       case 2:
       {
           cout<<"Enter account no.: ";
           cin>>k1;
           a[k1]->deposit();
           break;
       }
       case 3:
       {
           cout<<"Enter account no.: ";
           cin>>k1;
           a[k1]->withdrawal();
           break;
       }
       case 4:
       {
           cout<<"Enter the source and destination account nos.: ";
           cin>>k1>>j1;
           *a[j1]=a[k1]->transfermoney(*a[j1]);
           break;
       }
       case 5:
       {
           cout<<"Enter account no.: ";
           cin>>k1;
           a[k1]->viewaccdetails();
           break;
       }
   }cout<<" Do you wish to continue[Press 'Y' to continue or 'N' to exit menu]: ";
   cin>>ch1;
}while(ch1=='y'||ch1=='Y');
}
bankAccount bankAccount::transfermoneyBank(bankAccount a)
{
   long amt1;
   cout<<"Enter amount to be transferred: ";
   cin>>amt1;
   a.accbalance=a.accbalance+amt1;
   if(accbalance<amt1)
   {
       cout<<" Insufficient balance! Operation Cannot be performed!"<<endl<<endl;
   }
   else
   {
       accbalance=accbalance-amt;
   }
   return a;
}
void bankAccount::withdrawalBank()
{
   long amtdrawn1;
   cout<<"Enter amount to be withdrawn: ";
   cin>>amtdrawn1;
   if(accbalance<amtdrawn1)
       cout<<" Insufficient balance! Operation Cannot be performed!"<<endl<<endl;
   else
       accbalance=accbalance-amtdrawn1;
}
void bankAccount::depositBank()
{
   long dep1;
   cout<<"Enter amount to be deposited: ";
   cin>>dep1;
   accbalance+=dep1;
}
void bankAccount::newaccountBank()
{
   accnumber++;
   d.getdetails();
   accbalance=0;
}
void bankAccount::viewaccdetailsBank()
{
   cout<<endl<<endl<<"*********ASSIGNMENT BANK ACCOUNT DETAILS*********"<<endl;
   cout<<" --- ---- ------- ------- "<<endl;
   cout<<"Account no.: "<<accnumber<<endl;
   cout<<"Name: "<<d.custname<<endl;
   cout<<"Branch: "<<d.custbranch<<endl;
   cout<<"City: "<<d.custcity<<endl;
   cout<<"Current Balance: "<<accbalance<<endl;
   cout<<"_________________________________________"<<endl;
}