-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject.cpp
More file actions
327 lines (306 loc) · 7.03 KB
/
Copy pathproject.cpp
File metadata and controls
327 lines (306 loc) · 7.03 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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
#include<iostream>
#include<fstream>
#include<cctype>
#include<iomanip>
using namespace std;
class Bank_Account
{
int Money_Deposit;
char type;
int acno;
char name[70];
public:
void report() const;
int retMoney_Deposit() const;
void create_Bank_Account();
void dep(int);
int retacno() const;
void Display_Account() const;
void Updation();
char rettype() const;
void draw(int);
};
void Bank_Account::Updation()
{
cout<<"\n\tBank_Account No. : "<<acno;
cout<<"\n\tUpdation Bank_Account Holder Name : ";
cin.ignore();
cin.getline(name,50);
cout<<"\n\tUpdation Type of Bank_Account : ";
cin>>type;
type=toupper(type);
cout<<"\n\tUpdation Balance Total-Money : ";
cin>>Money_Deposit;
}
void Bank_Account::create_Bank_Account()
{
system("CLS");
cout<<"\n\tPlease Enter the Bank_Account No. : ";
cin>>acno;
cout<<"\n\n\tPlease Enter the Name of the Bank_Account holder : ";
cin.ignore();
cin.getline(name,50);
cout<<"\n\tPlease Enter Type of the Bank_Account (C/S) : ";
cin>>type;
type=toupper(type);
cout<<"\n\tPlease Enter The Starting Total-Money : ";
cin>>Money_Deposit;
cout<<"\n\n\tBank_Account Created..";
}
void Bank_Account::Display_Account() const
{
cout<<"\n\tBank_Account No. : "<<acno;
cout<<"\n\tBank_Account Holder Name : ";
cout<<name;
cout<<"\n\tType of Bank_Account : "<<type;
cout<<"\n\tBalance Total-Money : "<<Money_Deposit;
}
int Bank_Account::retacno() const
{
return acno;
}
char Bank_Account::rettype() const
{
return type;
}
void Bank_Account::report() const
{
cout<<acno<<setw(10)<<" "<<name<<setw(10)<<" "<<type<<setw(6)<<Money_Deposit<<endl;
}
void Bank_Account::dep(int x)
{
Money_Deposit+=x;
}
void Bank_Account::draw(int x)
{
Money_Deposit-=x;
}
int Bank_Account::retMoney_Deposit() const
{
return Money_Deposit;
}
void write_Bank_Account();
void display_sp(int);
void display_all();
void delete_Bank_Account(int);
void Money_Deposit_withdraw(int, int);
void Updation_Bank_Account(int);
int main()
{
char ch;
int num;
do
{
system("CLS");
cout<<"\n\t\t BANK MANAGEMENT SYSTEM ";
cout<<"\n\t\t1. NEW Bank_Account";
cout<<"\n\t\t2. Money_Deposit Total-Money";
cout<<"\n\t\t3. WITHDRAW Total-Money";
cout<<"\n\t\t4. BALANCE ENQUIRY";
cout<<"\n\t\t5. ALL Bank_Account HOLDER LIST";
cout<<"\n\t\t6. CLOSE AN Bank_Account";
cout<<"\n\t\t7. Updation AN Bank_Account";
cout<<"\n\t\t8. EXIT";
cout<<"\n\n\t\tSelect Your Option (1-8): ";
cin>>ch;
switch(ch)
{
case '1':
write_Bank_Account();
break;
case '2':
system("CLS");
cout<<"\n\n\tPlease Enter The Bank_Account No. : "; cin>>num;
Money_Deposit_withdraw(num, 1);
break;
case '3':
system("CLS");
cout<<"\n\n\tPlease Enter The Bank_Account No. : "; cin>>num;
Money_Deposit_withdraw(num, 2);
break;
case '4':
system("CLS");
cout<<"\n\n\tPlease Enter The Bank_Account No. : "; cin>>num;
display_sp(num);
break;
case '5':
display_all();
break;
case '6':
system("CLS");
cout<<"\n\n\tPlease Enter The Bank_Account No. : "; cin>>num;
delete_Bank_Account(num);
break;
case '7':
system("CLS");
cout<<"\n\n\tPlease Enter The Bank_Account No. : "; cin>>num;
Updation_Bank_Account(num);
break;
case '8':
system("CLS");
cout<<"\n\n\tBrought To You By code-projects.org";
break;
default :cout<<"\a";
}
cin.ignore();
cin.get();
}while(ch!='8');
return 0;
}
void write_Bank_Account()
{
Bank_Account ac;
ofstream outFile;
outFile.open("Bank_Account.dat", ios::binary| ios::app);
ac.create_Bank_Account();
outFile.write(reinterpret_cast<char *> (&ac), sizeof(Bank_Account));
outFile.close();
}
void delete_Bank_Account(int n)
{
Bank_Account ac;
ifstream inFile;
ofstream outFile;
inFile.open("Bank_Account.dat",ios::binary);
if(!inFile)
{
cout<<"File could not be open !! Press any Key...";
return;
}
outFile.open("Temp.dat",ios::binary);
inFile.seekg(0, ios::beg);
while(inFile.read(reinterpret_cast<char *> (&ac), sizeof(Bank_Account)))
{
if(ac.retacno()!=n)
{
outFile.write(reinterpret_cast<char *> (&ac), sizeof(Bank_Account));
}
}
inFile.close();
outFile.close();
remove("Bank_Account.dat");
rename("Temp.dat","Bank_Account.dat");
cout<<"\n\nRecord Deleted ..";
}
void display_sp(int n)
{
Bank_Account ac;
bool flag=false;
ifstream inFile;
inFile.open("Bank_Account.dat", ios::binary);
if(!inFile)
{
cout<<"File could not be open !! Press any Key...";
return;
}
cout<<"\n\tBALANCE DETAILS\n";
while(inFile.read(reinterpret_cast<char *> (&ac), sizeof(Bank_Account)))
{
if(ac.retacno()==n)
{
ac.Display_Account();
flag=true;
}
}
inFile.close();
if(flag==false)
cout<<"\n\n\tBank_Account number does not exist";
}
void display_all()
{
system("CLS");
Bank_Account ac;
ifstream inFile;
inFile.open("Bank_Account.dat", ios::binary);
if(!inFile)
{
cout<<"File could not be open !! Press any Key...";
return;
}
cout<<"\n\n\t\tBank_Account HOLDER LIST\n\n";
cout<<"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!========\n";
cout<<"A/c no. NAME Type Balance\n";
cout<<"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!========\n";
while(inFile.read(reinterpret_cast<char *> (&ac), sizeof(Bank_Account)))
{
ac.report();
}
inFile.close();
}
void Updation_Bank_Account(int n)
{
bool found=false;
Bank_Account ac;
fstream File;
File.open("Bank_Account.dat", ios::binary| ios::in|ios::out);
if(!File)
{
cout<<"File could not be open !! Press any Key...";
return;
}
while(!File.eof() && found==false)
{
File.read(reinterpret_cast<char *> (&ac), sizeof(Bank_Account));
if(ac.retacno()==n)
{
ac.Display_Account();
cout<<"\n\n\tPlease Enter The New Details of Bank_Account"<<endl;
ac.Updation();
int pos=(-1)*static_cast<int>(sizeof(Bank_Account));
File.seekp(pos, ios::cur); //fncallat1353
File.write(reinterpret_cast<char *> (&ac), sizeof(Bank_Account));
cout<<"\n\n\tRecord Updated";
found=true;
}
}
File.close();
if(found==false)
cout<<"\n\n\tRecord Not Found ";
}
void Money_Deposit_withdraw(int n, int option)
{
int amt;
bool found=false;
Bank_Account ac;
fstream File;
File.open("Bank_Account.dat", ios::binary|ios::in|ios::out);
if(!File)
{
cout<<"File could not be open !! Press any Key...";
return;
}
while(!File.eof() && found==false)
{
File.read(reinterpret_cast<char *> (&ac), sizeof(Bank_Account));
if(ac.retacno()==n)
{
ac.Display_Account();
if(option==1)
{
cout<<"\n\n\tTO Money_DepositSS Total-Money";
cout<<"\n\n\tPlease Enter The Total-Money to be Money_Deposited: ";
cin>>amt;
ac.dep(amt);
}
if(option==2)
{
cout<<"\n\n\tTO WITHDRAW Total-Money";
cout<<"\n\n\tPlease Enter The Total-Money to be withdraw: ";
cin>>amt;
int bal=ac.retMoney_Deposit()-amt;
if(bal<0)
cout<<"Insufficience balance";
else
ac.draw(amt);
}
int pos=(-1)*static_cast<int>(sizeof(ac));
File.seekp(pos, ios::cur);//fn1353
File.write(reinterpret_cast<char *> (&ac), sizeof(Bank_Account));
cout<<"\n\n\tRecord Updated";
found=true;
}
}
File.close();
if(found==false)
cout<<"\n\n\tRecord Not Found ";
}