#include<iostream>
#include<stdlib.h>
using namespace std;
class bank
{
public:
char customerName[20];
int mobileNo,aadharNo;
bank()
{
cout<<"\nEnter name of customer : ";
cin>>customerName;
cout<<"\nEnter aadhar no. : ";
cin>>aadharNo;
cout<<"\nEnter mobile no. : ";
cin>>mobileNo;
}
virtual void transaction()=0;
};
class sbi:virtual public bank
{
public:
int sbibal=0;
int* ptr;
static int sbiacc_no;
int sbiacc=++sbiacc_no;
void transaction();
};
int sbi::sbiacc_no=0;
void sbi::transaction()
{
int ch,dAmt,wAmt;
do
{
cout<<"\nSelect type of transaction : ";
cout<<"\n1. Deposit.\n2. Withdraw.\n3. Balance Enquiry.\n4. Exit.";
cout<<"\nEnter your choice : ";
cin>>ch;
switch(ch)
{
case 1:
cout<<"Enter amount to be deposited : ";
cin>>dAmt;
sbibal=sbibal+dAmt;
cout<<"Balance is : ";
cout<<sbibal;
break;
case 2:
cout<<"Enter amount to withdraw : ";
cin>>wAmt;
if(wAmt<sbibal)
{
sbibal=sbibal-wAmt;
cout<<"Balance is : ";
cout<<sbibal;
}
else
{
cout<<"Insufficient balance.";
}
break;
case 3:
cout<<"Balance is : ";
cout<<sbibal;
break;
case 4:
continue;
}
}while(ch<4);
}
class boi:virtual public bank
{
public:
int boibal=0;
int* str;
static int boiacc_no;
int boiacc=++boiacc_no;
void transaction();
};
int boi::boiacc_no=0;
void boi::transaction()
{
int ch,dAmount,wAmount;
do
{
cout<<"\nSelect type of transaction : ";
cout<<"\n1. Deposit.\n2. Withdraw.\n3. Balance Enquiry.\n4. Exit.";
cout<<"\nEnter your choice : ";
cin>>ch;
switch(ch)
{
case 1:
cout<<"Enter amount to be deposited : ";
cin>>dAmount;
boibal=boibal+dAmount;
cout<<"Balance is : ";
cout<<boibal;
break;
case 2:
cout<<"Enter amount to withdraw : ";
cin>>wAmount;
if(wAmount<boibal)
{
boibal=boibal-wAmount;
cout<<"Balance is : ";
cout<<boibal;
}
else
{
cout<<"Insufficient balance.";
}
break;
case 3:
cout<<"Balance is : ";
cout<<boibal;
break;
case 4:
continue;
}
}while(ch<4);
}
/*class agent:public sbi,public boi
{
public:
int sbiloanamt=0;
int boiloanamt=0;
int choice;
void transaction()
{
cout<<"\nSelect your bank : ";
cout<<"\n1. SBI.\n2. BOI.";
if(choice==1)
{
cout<<"\nEnter amount required : ";
cin>>sbiloanamt;
sbibal=sbibal+sbiloanamt;
cout<<"\nBalance after loan : "<<sbibal;
}
else
{
cout<<"\nEnter amount required : ";
cin>>boiloanamt;
boibal=boibal+boiloanamt;
cout<<"\nBalance after loan : "<<boibal;
}
}
};*/
int main()
{
int input;
int opt;
jump:
do
{
cout<<"\nIn which bank you wish to open account?";
cout<<"\n1. SBI.\n2. BOI.";
cout<<"\nEnter your choice : ";
cin>>input;
switch(input)
{
case 1:
{
sbi s;
cout<<"\nAccount created in SBI successfully.";
cout<<"\nYour account no. is : "<<s.sbiacc;
s.transaction();
goto jump;
}
case 2:
{
boi b;
cout<<"\nAccount created in BOI successfully.";
cout<<"\nYour account no. is : "<<b.boiacc;
b.transaction();
goto jump;
}
case 3:
{
exit(0);
break;
}
}
}while(input<4);
return 0;
}