-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBankingProject.cpp
More file actions
300 lines (287 loc) · 7.47 KB
/
BankingProject.cpp
File metadata and controls
300 lines (287 loc) · 7.47 KB
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <iomanip>
#include <conio.h>
using namespace std;
class bank
{
private:
double cash;
double accno;
double dep;
double wit;
char name[50];
public:
void getdata()
{
cout<<"\t\tEnter Account Number : \t";
cin>>accno;
cout<<"\t\tName : \t\t\t";
gets(name);
cout<<"\t\tInitial Deposit : \t";
cin>>cash;
}
void showdata()
{
cout<<"\t\tAccount Number : \t"<<accno<<endl;
cout<<"\t\tName : \t\t\t"<<name<<endl;
cout<<"\t\tInitial Deposit : \t"<<cash<<endl<<endl<<endl;
}
void deposit()
{
cout<<"\t\tAccount Number : \t"<<accno<<endl;
cout<<"\tAccount Holder's Name : \t"<<name<<endl;
cout<<"\tAccount Holder's Funds : \t"<<cash<<endl;
cout<<"\t\tEnter Deposit : \t";
cin>>dep;
cash=cash+dep;
cout<<"\tAccount Holder's New Funds : \t"<<cash<<endl;
}
void withdrawal()
{
cout<<"\t\tAccount Number : \t"<<accno<<endl;
cout<<"\tAccount Holder's Name : \t"<<name<<endl;
cout<<"\tAccount Holder's Funds : \t"<<cash<<endl;
cout<<"\tEnter Withdrawal Amount : \t";
cin>>wit;
if (cash-wit>=0)
{
cash=cash-wit;
cout<<"\tAccount Holder's New Funds : \t"<<cash<<endl;
}
else
{
cout<<"\t\tNOT ENOUGH FUNDS"<<endl;
}
}
int retaccno()
{
return accno;
}
};
void write()
{
cout<<endl<<endl;
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
cout<<"\t\t\t CREATING A NEW ACCOUNT "<<endl<<endl;
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl<<endl;
fstream outfile;
outfile.open("Bankinga.dat",ios::out|ios::binary|ios::app);
bank obj;
obj.getdata();
outfile.write((char *)&obj,sizeof(obj));
outfile.close();
}
void display()
{
cout<<endl<<endl;
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
cout<<"\t\t\t ACCOUNTS "<<endl<<endl;
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl<<endl;
fstream infile;
infile.open("Bankinga.dat",ios::in|ios::binary);
bank obj;
while(infile.read((char*)&obj,sizeof(obj)))
{
obj.showdata();
}
infile.close();
if (infile.eof())
{
cout<<"\t\tNo Accounts Exist"<<endl;
}
}
void search(int n)
{
cout<<endl<<endl;
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
cout<<"\t\t\t SEARCHING "<<endl<<endl;
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl<<endl;
ifstream infile;
infile.open("Bankinga.dat",ios::binary);
bank obj;
if(!infile.eof())
{
while(infile.read((char*)&obj,sizeof(obj)))
{
if(obj.retaccno()==n)
{
obj.showdata();
}
}
}
infile.close();
}
void delete_rec(int n)
{
cout<<endl<<endl;
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
cout<<"\t\t\t DELETING "<<endl<<endl;
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl<<endl;
bank obj;
ifstream infile;
infile.open("Bankinga.dat",ios::binary);
ofstream outfile;
outfile.open("BankingT.dat",ios::out|ios::binary);
while(infile.read((char*)&obj, sizeof(obj)))
{
if(obj.retaccno()!=n)
{
outfile.write((char*)&obj,sizeof(obj));
}
}
infile.close();
outfile.close();
remove("Bankinga.dat");
rename("BankingT.dat","Bankinga.dat");
}
void modify(int n)
{
cout<<endl<<endl;
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
cout<<"\t\t\t MODIFY "<<endl<<endl;
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl<<endl;
fstream file;
file.open("Bankinga.dat",ios::in|ios::out|ios::binary);
bank obj;
while(file.read((char*)&obj, sizeof(obj)))
{
if(obj.retaccno()==n)
{
cout<<"Enter new details"<<endl;
obj.getdata();
int pos=(file.tellp() - sizeof(obj));
file.seekp(pos);
file.write((char*)&obj,sizeof(obj));
}
}
file.close();
}
void modifywithdrawal(int n)
{
cout<<endl<<endl;
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
cout<<"\t\t\t WITHDRAWAL "<<endl<<endl;
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl<<endl;
fstream file;
file.open("Bankinga.dat",ios::in|ios::out|ios::binary);
bank obj;
while(file.read((char*)&obj, sizeof(obj)))
{
if(obj.retaccno()==n)
{
obj.withdrawal();
int pos=(file.tellp() - sizeof(obj));
file.seekp(pos);
file.write((char*)&obj,sizeof(obj));
}
}
file.close();
}
void modifydeposit(int n)
{
cout<<endl<<endl;
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
cout<<"\t\t\t DEPOSIT "<<endl<<endl;
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl<<endl;
fstream file;
file.open("Bankinga.dat",ios::in|ios::out|ios::binary);
bank obj;
while(file.read((char*)&obj, sizeof(obj)))
{
if(obj.retaccno()==n)
{
obj.deposit();
int pos=(file.tellp() - sizeof(obj));
file.seekp(pos);
file.write((char*)&obj,sizeof(obj));
}
}
file.close();
}
int main()
{
int choice;
char loop, yes;
do
{
system("CLS");
flag:
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
cout<<"\t\t\t\t WELCOME"<<endl;
cout<<"\t\t\t\t TO"<<endl;
cout<<"\t\t\t RED DRAGON BANK"<<endl;
cout<<"\t\t https://github.com/AryanFelix"<<endl<<endl;
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl<<endl;
cout<<"\t\t How can we help you today?"<<endl;
cout<<"\t\t Press the adjacent number"<<endl<<endl;
cout<<"\t\t\t 1. Create an account"<<endl<<endl;
cout<<"\t\t\t 2. Display details of all existing account"<<endl<<endl;
cout<<"\t\t\t 3. Search for a specific account"<<endl<<endl;
cout<<"\t\t\t 4. Delete an account"<<endl<<endl;
cout<<"\t\t\t 5. Modify an account"<<endl<<endl;
cout<<"\t\t\t 6. Deposit"<<endl<<endl;
cout<<"\t\t\t 7. Withdrawal"<<endl<<endl;
cout<<"\t\t\t 8. Exit"<<endl<<endl;
cout<<"\t\t Enter your selection : ";
cin>>choice;
system("CLS");
switch (choice)
{
case 1 : system("CLS");
write();
break;
case 2 : system("CLS");
display();
break;
case 3 : system("CLS");
int n;
cout<<"\t\tEnter Account Number To Be Searched : ";
cin>>n;
search(n);
break;
case 4 : system("CLS");
int m;
cout<<endl<<endl<<"\t\tEnter Account Number To Be Deleted : ";
cin>>m;
delete_rec(m);
break;
case 5 : system("CLS");
int b;
cout<<endl<<endl<<"\t\tEnter Account Number To Be Modified : ";
cin>>b;
modify(b);
break;
case 6 : system("CLS");
int z;
cout<<endl<<endl<<"\t\tEnter Account Number To Be Deposited Into : ";
cin>>z;
modifydeposit(z);
break;
case 7 : system("CLS");
int y;
cout<<endl<<endl<<"\t\tEnter Account Number To Be Withdrawn From : ";
cin>>y;
modifywithdrawal(y);
break;
case 8 : break;
default : cout<<"\t\t INVALID"<<endl;
cout<<"\t\t ";
getch();
system("CLS");
goto flag;
}
if (choice==8)
{
break;
}
cout<<"\n\n\t\t Do you wish to continue availing our services? \n\t\t (Y for yes and N for no)"<<endl;
cin>>yes;
}while(yes=='Y'||yes=='y');
system("CLS");
cout<<"\t\tThank you for using our online portal"<<endl;
cout<<"\t\t\t RED DRAGON BANK"<<endl<<endl;
cout<<"\t\t https://github.com/AryanFelix"<<endl<<endl;
return 0;
}