Home >> Sem 2 >> C++ programs >> BANK
/* Write a Bank Program for Deposite, Withdraw for perticular account member*/
#include<iostream.h>
#include<conio.h>
#include<process.h>
#include<iomanip.h>
static flag;
class bank
{
int ac_no;
char name[20],type;
long int balance;
public:
bank()
{
balance = 1000;
}
void insert();
void disp();
void withdraw(int);
void deposit(int);
};
void bank::deposit(int acno)
{
int dep;
if(acno==ac_no)
{
cout<<"Enter Deposit : ";
cin>>dep;
balance = balance + dep;
}
}
void bank::insert()
{
int temp;
cout<<"\nEnter an account Number : ";
cin>>ac_no;
cout<<"Enter Name Of Customer : ";
cin>>name;
cout<<"Enter Type of account. ( S / C) : ";
cin>>type;
cout<<"Enter Balance of Customer : ";
cin>>temp;
balance+=temp;
}
void bank::disp()
{
cout<<endl<<setw(5)<<ac_no<<setw(10)<<name<<" "<<type<<setw(10)<<balance;
}
void bank::withdraw(int acno)
{
static int amt;
if(ac_no==acno)
{
cout<<"\nEnter amount that u want to withdraw ===> ";
cin>>amt;
balance-=amt;
flag=1;
}
}
void main()
{
int choice,i,acno,amt;
clrscr();
do
{
cout<<endl<<"\n1 : Insert information about Customer."<<endl;
cout<<"2 : Display information of all customer."<<endl;
cout<<"3 : Withdraw amount from an account."<<endl;
cout<<"4 : Deposite amount from account."<<endl;
cout<<"5 : Exit from program."<<endl;
cout<<"Enter your choice : "<<endl;
cin>>choice;
switch(choice)
{
case 1:
cout<<"\n\t######## Enter information about customer.######## ";
bank cust[3];
for(i=0;i<3;i++)
{
cust[i].insert();
}
break;
case 2:
cout<<"Acc_no"<<setw(10)<<"Name"<<setw(10)<<"Type"<<setw(10)<<"Balance"<<endl;
for(i=0;i<=40;i++)
cout<<"=";
for(i=0;i<3;i++)
{
cust[i].disp();
}
break;
case 3:
flag = 0;
cout<<"\nEnter an account number : ";
cin>>acno;
if(flag==0)
for(i=0;i<3;i++)
cust[i].withdraw(acno);
break;
case 4:
cout<<"\nEnter an account number : ";
cin>>acno;
for(i=0;i<3;i++)
cust[i].deposit(acno);
break;
case 5:
exit(0);
default :
cout<<"\n\n\t\t####### invalid Choice #######\n";
}
}while(1);
}