Bank Management System Source Code
Bank Management System Source Code
#include<string>
#include<conio.h>
using namespace std;
class Bank{
private:
int total;
string id;
struct person{
string name;
string ID, address;
long long contact;
int cash;
} person[100];
public:
Bank(){
total=0;}
void choice();
void perData();
void show();
void update();
void search();
void transactions();
void del();
};
int main()
{ Bank b;
b.choice();
return 0;
}
void Bank:: choice()
{
char ch;
while(1)
{
cout<<"................................"<<endl;
cout<<"................................"<<endl;
cout<< endl<< " WELCOME TO CU BANK"<< endl;
cout<<"................................"<<endl;
cout<<"................................"<<endl;
cout<<"Choose a number to continue: "<<endl <<endl;
cout<<"1. Create new account"<<endl;
cout<<"2. View customers list"<<endl;
cout<<"3. Update information of existing account"<<endl;
cout<<"4. Check the details of an existing account"<<endl;
cout<<"5. For transactions"<<endl;
cout<<"6. Remove existing account"<<endl;
cout<<"7. Exit"<<endl <<endl;
ch= getch();
switch(ch)
{
case '1':
Bank:: perData();
break;
case '2':
if(total==0)
{
cout<<"No data is entered"<<endl;
}else
{
Bank::show();
}
break;
case '3':
Bank:: update();
break;
case '4':
Bank:: search();
break;
case '5':
Bank:: transactions();
break;
case '6':
Bank:: del();
break;
case '7':
exit(0);
break;
default:
cout<< " Invalid input" <<endl;
break;
}
}
void Bank::perData()
{
cout<<"Enter data of person "<<total+1<<endl;
cout<< "use underscore (_) instead of space "<< endl;
cout<<endl<<"Enter name: "<<endl;
cin>>person[total].name;
cout<<endl<<"Address: ";
cin>>person[total].address;
cout<<endl<<"ID: ";
cin>>person[total].ID;
cout<<endl<<"Contact: ";
cin>>person[total].contact;
cout<<endl<<"Total Cash: ";
cin>>person[total].cash;
cout<< endl<<"......"<<endl<< " Your account has been created! "<<endl;
total++;
void Bank::show()
{
for(int i=0;i<total;i++){
cout<<endl<<"Data of person "<<i+1<<endl;
cout<<"Name: "<<person[i].name<<endl;
cout<<"ID: "<<person[i].ID<<endl;
cout<<"Address: "<<person[i].address<<endl;
cout<<"Contact: "<<person[i].contact<<endl;
cout<<"Cash: "<<person[i].cash<<endl;
}
}
void Bank::update()
{
cout<<"Enter id of student those data you want to update"<<endl;
cin>>id;
for(int i=0;i<total;i++)
{
if(id == person[i].ID){
cout<<" Previous data: "<< endl;
cout<<"Data of person "<<i+1<<endl;
cout<<"Name: "<<person[i].name<<endl;
cout<<"ID: "<<person[i].ID<<endl;
cout<<"Address: "<<person[i].address<<endl;
cout<<"Contact: "<<person[i].contact<<endl;
cout<<"Cash: "<<person[i].cash<<endl;
}if(i==total-1){
cout<<"No such record found"<<endl;
}
}
}
void Bank:: search()
{
cout<<"Enter ID of person whose data you want to check: "<<endl;
cin>> id;
for (int i=0; i<total; i++){
if(id == person[i].ID) {
cout<<"Name: "<<person[i].name<<endl;
cout<<"ID: "<<person[i].ID<<endl;
cout<<"Address: "<<person[i].address<<endl;
cout<<"Contact: "<<person[i].contact<<endl;
cout<<"Cash: "<<person[i].cash<<endl;
break;
} if(i==total-1){
cout<<"No such record found"<<endl;
}
}
}
void Bank:: transactions()
{
int cash;
char ch;
cout<<"Enter ID of the person: "<<endl;
cin>> id;
for (int i=0; i<total; i++){
if(id == person[i].ID) {
cout<<"Name: "<<person[i].name<<endl;
cout<<"Address: "<<person[i].address<<endl;
cout<<"Contact: "<<person[i].contact<<endl;
cout<<"\nExisting Cash "<<person[i].cash<<endl;
cout<<"Press 1 to deposit"<<endl;
cout<<"Press 2 to withdraw"<<endl;
ch= getch();
switch(ch) {
case '1':
cout<< "How much cash you want to deposit?" << endl;
cin>> cash;
person[i].cash += cash;
cout<< "Your new cash is: " << person[i].cash;
break;
case '2':
back:
cout<< endl<< "How much cash you want to withdraw?" <<endl;
cin>> cash;
if(cash>person[i].cash){
cout<<"You dont have sufficient balance"<<endl;
goto back;
}
person[i].cash -= cash;
cout<< "Your new cash is: " << person[i].cash;
break;
default:
cout<<"Invalid Input"<<endl;
break;
} break;
} if(i==total-1){
cout<<"No such record found"<<endl;
}
}
}
void Bank:: del()
{
char ch;
cout<< " Press 1 to remove a specific record" <<endl;
cout<<" Press 2 to remove full record" <<endl;
ch = getch();
switch (ch) {
case '1':
cout<<"Enter ID of the person: "<<endl;
cin>> id;
for(int i=0;i<total;i++){
if(id==person[i].ID){
for(int j=i;j<total;j++){
person[j].name= person[j+1].name;
person[j].ID= person[j+1].ID;
person[j].address= person[j+1].address;
person[j].contact= person[j+1].contact;
person[j].cash= person[j+1].cash;
total --;
cout<<"Your required data is deleted"<<endl;
break;
}
} if(i=total-1){
cout<<"No such record found"<<endl; }
} break;
case '2':
total=0;
cout<<"All record is deleted"<<endl;
break;
default:
cout<<"Invalid Input"<<endl;
break;
}
}