OOP/CPP Bank class to deposit, withdraw and display balance of accounts

#include<iostream>
using namespace std;
class bank
{
 char d_n[45];
 int a_n;
 char t_a[45];
 int  m;
 public:
  void getdata();
  int deposit(int b,char a[],int c);
  int withdraw(int b,char a[],int c);
  void display();
};
void bank::getdata()
{
cout<<“\n\n Enter a depositor’s name = “;
cin>> d_n;
cout<<“\n Enter the account number = “;
cin>>a_n;
cout<<“\n Type of the account = “;
cin>>t_a;
cout<<“\n Enter amount in the account = “;
cin>>m;
}
int bank::deposit(int b, char a[],int c)
{
  char *q,*p;
    q=a;
    p=d_n;
 if(*q==*p && b==a_n)
  {
     m = m + c ;
     cout<<“\n\n Now, Your bank balance is = “<<m;
     return 1;
  }
 return 0;
}
int bank::withdraw(int b, char a[],int c)
{
  char *q,*p;
    q=a;
    p=d_n;
   if(*q==*p && b==a_n)
   {
if(c<=m)
{
  cout<<“\n\n Your check is acecpted. “;
  m=m-c;
cout<<“\n Now, \n  The amount of money remain in your account is = “<<m;
}
else
{
   cout<<“\n\n Your check is not acecpted. “;
   cout<<“\n Your amount in the account is = “<<m;
}
return 1;
    }
   return 0;
}
void bank::display()
{
 cout<<“\n Name = “<<d_n;
 cout<<“\n Account number = “<<a_n;
 cout<<“\n Type of account = “<<t_a;
 cout<<“\n The amount of money in the account = “<<m;
}
int main(void)
{
int n,i,b,c,d=0,p;
char a[45];
bank x[45];
cout<<“\n\n  How many depositor’s information do you want to enter = “;
cin>>n;
for(i=0;i<n;i++)
   {
cout<<“\n Information of depositor “<<i+1;
cout<<“\n——————————-“;
x[i].getdata();
   }
do{
  cout<<“\n\n You can do the following things :”;
  cout<<“\n\n [1]. Deposite an amount of money. “;
  cout<< “\n [2]. Withdraw an amount of money.”;
  cout<<“\n [3]. Display the name and the balance of the depositor.”;
  cout<<“\n [4]. Quit.”;
  cout<<“\n\n Enter your choose = “;
  cin>>p;
 switch(p)
  {
     case 1 :
cout<<“\n\n Enter the following information :”;
cout<<“\n\n Your name = “;
cin>>a;
cout<<“\n Account number = “;
cin>>b;
cout<<“\n The amount of money  = “;
cin>>c;
for(i=0;i<n;i++)
{
d= x[i].deposit(b,a,c);
if(d==1) break;
}
if(d==0)
{
  cout<<“\n\n You have enter incorrect name or accont number.”;
  cout<<“\n\n Please, enter the correct information.”;
}
break;
     case 2:
cout<<“\n\n Enter the following information :”;
cout<<“\n\n Your name = “;
cin>>a;
cout<<“\n Account number = “;
cin>>b;
cout<<“\n The amount of your check = “;
cin>>c;
for(i=0;i<n;i++)
   {
d=x[i].withdraw(b,a,c);
if (d==1)
  break;
    }
if(d==0)
{
cout<<“\n\n You have enter incorrect name or account number.”;
cout<<“\n\n Please, enter the correct information.”;
}
break;
   case 3:
cout<<“\n\n  The list of the depositors in the bank are shown below:”;
for(i=0;i<n;i++)
{
cout<<“\n\n Depositor #”<<i+1<<“\n”;
cout<<“—————“;
x[i].display();
}
break;
  case 4: break;
   default:
cout<<“\n\n Wrong choice.”;
cout<<“\n\n Please, choose any of the above option and try again.”;
break;
    }
 }  while(p!=4);
}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>