#include
#include
#include
#include
class bank
{
public:
int acno[50];
char name[50][15];
char type[50][15];
int typenum[50];
float bal[50];
static int max;
void create(int,int);
void deposit(int,int);
void withdraw(int,int);
void interest(int,int);
void balance(int,int);
};
int bank::max;
void bank::create(int no,int fs)
{
int k,i;
float ba;
char na[5];
for(i=0;i
if(acno[i]==no)
{
cout<<"Account number already Exist\n";
getch();
return;
}
a:
cout<<"Enter name:";
cin>>na;
for(k=0;k
if((na[k]>=97&&na[k]<=122)||(na[k]>=65 && na[k]<=90))
continue;
else
{
cout<<"Name must be an alphabet\n";
goto a;
}
bal:
cout<<"Enter Initial Deposit:";
cin>>ba;
if(ba>=500)
{
acno[max]=no;
strcpy(name[max],na);
bal[max]=ba;
flushall();
if(fs==1)
{
typenum[max]=1;
strcpy(type[max],"Current Account");
}
else if(fs==2)
{
typenum[max]=2;
strcpy(type[max],"SavingAccount");
}
balance(acno[max++],fs);
}
else
{
cout<<"Accont must be greater than 500";
goto bal;
}
getch();
}
void bank::deposit(int no,int f)
{
int i;
float ba;
for(i=0;i
if(acno[i]==no && typenum[i]==f)
{
cout<<"Enter the amount:";
cin>>ba;
if(ba>0)
{
bal[i]+=ba;
balance(acno[i],f);
getch();
return;
}
else
{
cout<<"Invalid Amount";
getch();
return;
}
}
cout<<"Account not found\n";
getch();
}
void bank::withdraw(int no,int f)
{
int i,fl=0;
float ba;
for(i=0;i
{
if(acno[i]==no && typenum[i]==f)
{
fl=1;
cout<<"Enter Amount:";
cin>>ba;
if(ba>0)
{
if((bal[i]-ba)>=500)
{
bal[i]-=ba;
cout<<"Account Number:"<
getch();
return;
}
else
cout<<"Balance is too low\nCurrent Balance:"<
}
else
cout<<"Invalid amount\n";
}
}
if(fl==0)
cout<<"Account not found";
getch();
}
void bank::interest(int no,int f)
{
int y,i,in,fl=0;
for(i=0;i
if(acno[i]==no && typenum[i]==f)
{
fl=1;
cout<<"Enter Interest in %:";
cin>>in;
cout<<"Enter number of years:";
cin>>y;
if(in>0 && y>0)
{
bal[i]=bal[i]+(bal[i]*y*in/100);
balance(acno[i],f);
}
}
if(fl==0)
cout<<"Account not found";
getch();
}
void bank::balance(int no,int f)
{
int i,j,fl=0;
for(i=0;i
if(acno[i]==no && typenum[i]==f)
{
fl=1;
for(j=0;j<60;j++)
cout<<"-";
cout<<"\nAccountNo\tName\t\tBalance\t\tAccountType\n";
for(j=0;j<60;j++)
cout<<"-";
cout<<"\n"<
getch();
return;
}
if(fl==0)
cout<<"Account not found";
getch();
}
void main()
{
int op,no,f;
char t[15];
bank b;
while(1)
{
x:
clrscr();
cout<<"\t\tBANKING SYSTEM\n"<<"\t\t~~~~~~~~~~~~~~~~~~\n";
cout<<"1.Current Account\n2.Saving Account\n3.Exit\nOption:";
cin>>f;
while(1)
{
clrscr();
if(f==1)
cout<<"\n\tCURRENT ACCOUNT\n1.New\n2.Deposit\n3.Withdraw\n4.Balance\n5.Exit\nOption:";
else if(f==2)
cout<<"\nSAVING ACCOUNT\n\n1.New\n2.Deposit\n3.Withdraw\n4.Balance\n5.Interest\n6.Exit\nOption:";
else
exit(0);
cin>>op;
switch(op)
{
case 1:
cout<<"Enter acno:";
cin>>no;
if(f==1)
b.create(no,1);
else
b.create(no,2);
break;
case 2:
cout<<"Enter acno:";
cin>>no;
b.deposit(no,f);
break;
case 3:
cout<<"Enter acno:";
cin>>no;
b.withdraw(no,f);
break;
case 4:
cout<<"Enter acno:";
cin>>no;
b.balance(no,f);
break;
case 5:
if(f==1)
goto x;
else
{
cout<<"Enter acno:";
cin>>no;
b.interest(no,f);
break;
}
case 6:
if(f==1)
{
cout<<"Invalid";
break;
}
else
goto x;
}
}
}
}