-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbankingsystem.cpp
188 lines (186 loc) · 6.35 KB
/
bankingsystem.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#include<bits/stdc++.h>
#include<Windows.h>
using namespace std;
class BANK{
char accountholdername[20];
long int accountnumber;
int totalbalance;
public:
int deposit;
int withdraw;
int ac;
char enteredpassword[20];
char enteredusername[20];
char username[20];
char password[20];
void enterdata();
void enter();
void showdata();
void write();
void read();
void update();
void Delete();
void Search(int);
void check();
void withdrawl();
void Deposit();
}B;
int Count=0;
char ch;
void BANK::enterdata(){
cout<<"ENTER THE NAME OF ACCOUNT HOLDER\n";
cin.ignore(numeric_limits<streamsize>::max(),'\n');
gets(accountholdername);
cout<<"ENTER THE ACCOUNT NUMBER\n";
cin>>accountnumber;
cout<<"ENTER YOUR TOTAL BALANCE\n";
cin>>totalbalance;
cout<<"ENTER YOUR USERNAME\n";
cin.ignore(numeric_limits<streamsize>::max(),'\n');
gets(username);
cout<<"ENTER YOUR PASSWORD\n";
gets(password);
}
void BANK::showdata(){
cout<<"ACCOUNT HOLDER:"<<accountholdername<<endl;
cout<<"ACCOUNT NUMBER:"<<accountnumber<<endl;
cout<<"TOTAL BALANCE:"<<totalbalance<<endl;
}
void BANK::write(){
ofstream outfile;
outfile.open("record.dat",ios::binary|ios::app);
enterdata();
outfile.write((char*)&B,sizeof(BANK));
for(int i=0;i<20;i++){
enteredpassword[i]=password[i];
}
for(int i=0;i<20;i++){
enteredusername[i]=username[i];
}
outfile.close();
}
void BANK::check()
{
cout<<"REENTER THE USERNAME AND PASSWORD FOR CONFIRMATION\n";
cout<<"ENTER YOUR USERNAME\n";
cin.ignore(numeric_limits<streamsize>::max(),'\n');
gets(username);
cout<<"ENTER YOUR PASSWORD\n";
gets(password);
ofstream outfile;
outfile.open("record.dat",ios::binary|ios::app);
while(!outfile.eof()){
if(strcmp(enteredpassword,B.password)==0 && strcmp(enteredusername,B.username)==0)
{
cout<<"ACCESS GRANTED";
break;
Count++;
}
else
{
cout<<"your username or password is wrong\n";
break;
}
}
}
void BANK::read(){
ifstream infile;
infile.open("record.dat",ios::binary);
if(!infile)
{
cout<<"ERROR IN OPENING FILE\n";
return;
}
cout<<"DATA YOU HAVE ENTERED\n";
while(!infile.eof())
{
if(infile.read((char*)&B,sizeof(BANK)))
{
showdata();
}
}
infile.close();
}
void BANK::Deposit()
{
check();
cout<<"\nENTER THE AMOUNT YOU WANT TO DEPOSIT\n";
cin>>deposit;
totalbalance+=deposit;
cout<<"\nAMOUNT DEPOSITED:"<<deposit<<"\nYOUR TOTAL BALANCE:"<<totalbalance;
}
void BANK::withdrawl()
{ check();
cout<<"\nENTER THE AMOUNT YOU WANT TO WITHDRAW\n";
cin>>withdraw;
totalbalance-=withdraw;
cout<<"AMOUNT WITHDRAWN:"<<withdraw<<"\nYOUR TOTAL BALANCE:"<<totalbalance;
}
void BANK::Search(int ac){
cout<<"ENTER THE ACCOUNT NUMBER<<endl";
cin>>ac;
if(accountnumber==ac)
cout<<"SEARCH SUCCESSFUL YOUR ACCOUNT WAS FOUND<<endl";
else
cout<<"SEARCH FAILED";
}
int main(){
cout<<" ### # # # # # # # # ##### # # # # # # ##### ##### # # ###### # # ########"<<endl;
Sleep(500);
cout<<" # # # # ## # # # # ## # # # ## ## # # ## # # # # # # ## ## # ## # #"<<endl;
Sleep(500);
cout<<" # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #"<<endl;
Sleep(500);
cout<<" ### ###### # # # ## # # # # # # # # ###### # # # ###### # #### # # # #### # # # #"<<endl;
Sleep(500);
cout<<" # # # # # # # # # # # # # # ## # # # # # # # # # # ## # # # # # # # #"<<endl;
Sleep(500);
cout<<" # # # # # ## # # # # ## # # # # # # # ## # # # # # # # # # ## #"<<endl;
Sleep(500);
cout<<" # # # # # # # # # # # ##### # # # # # # # # ##### ##### # # ###### # # #"<<endl;
Sleep(500);
cout<<" ####### # # ###### ####### ###### # #"<<endl;
Sleep(500);
cout<<" # # # # # # # # ##"<<endl;
Sleep(500);
cout<<" # # # # # # # # # #"<<endl;
Sleep(500);
cout<<" ####### # ###### # #### # # #"<<endl;
Sleep(500);
cout<<" # # # # # # #"<<endl;
Sleep(500);
cout<<" # # # # # # #"<<endl;
Sleep(500);
cout<<" ####### # ###### # ###### # #"<<endl;
Sleep(500);
a: cout<<"\n\n\n\n\n\t\t\t\t\t\t\t\tWELCOME TO BANKING MANAGEMENT SYSTEM\n\t\t\t\t\t\t\t\tPRESS 1 FOR ENTERING DATA\n\t\t\t\t\t\t\t\tPRESS 2 FOR SHOWING ENTERED DATA\n\t\t\t\t\t\t\t\tPRESS 3 FOR UPDATING DATA\n\t\t\t\t\t\t\t\tPRESS 4 FOR DEPOSITING MONEY\n\t\t\t\t\t\t\t\tPRESS 5 FOR WITHDRAWLING MONEY\n\t\t\t\t\t\t\t\tPRESS 6 FOR EXIT\n\t\t\t\t\t\t\t\t";
do{
int n, ac;
cin>>n;
switch(n){
case 1:
B.write();
break;
case 2:
B.check();
break;
case 3:
B.read();
break;
case 4:
B.withdrawl();
break;
case 5:
B.Deposit();
break;
case 6:
exit(0);
break;
default:
cout<<"WRONG INPUT";
}
cout<<"\nWANNA CHECK MORE:";
cin>>ch;
}while(ch=='y'||ch=='Y');
return 0;
}