-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcbm cbdc
463 lines (421 loc) · 8.66 KB
/
cbm cbdc
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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
https://www.mcbsresbank.com/internet-banking-and-cbdc
#include <fstream.h>
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<process.h>
#include<stdio.h>
#include<dos.h>
void password(void)
{
int counter=0;
char username[20];
char password[15];
char str[20];
fstream user;
fstream pass;
user.open("username.dat",ios::binary|ios::in|ios::out);
pass.open("password.dat",ios::binary|ios::in|ios::out);
do
{
clrscr();
cout<<"\n\n\n\n\n\t\t\t USERNAME ";
cout<<"\n\n\t\t ";
gets(username);
user.read((char*) &str,sizeof(str));
user.close();
if(strcmp(str,username)==0)
{
clrscr();
cout<<"\n\n\n\n\n\t\t\tPASSWORD ";
cout<<"\n\n\t\t ";
gets(password);
pass.read((char*) &str,sizeof(str));
pass.close();
if(strcmp(str,password)==0)
{ clrscr();
cout<<"\n\n\n\n\t\t\tACCESS ALLOWED....";
delay(1500);
return;
}
else
{
cout<<"\n\n\t\t\tACCESS DENIED!!!!";
delay(2500);
continue;
}
}
counter++;
}while(counter<3);
clrscr();
cout<<"\n\n\n\n\n\n\t\t\t";
char arr[35]={"CLOSING DUE TO SECURITY THREAT"};
for(int i=0;i<35;i++)
{ cout<<arr[i];
delay(50);
}
cout<<"....";
delay(2500);
exit(0);
}
class account
{
char first_name[50],last_name[50],address[100],city[50],state[50];
char phone_number[25],pincode[25];
int accno, acctno;
float amount, deposit,rate;
public:
account()
{
amount=$10000.00;
deposit=0.00;
rate = 0.0;
ifstream fin;
fin.open("acctno.dat",ios::in);
fin>>acctno;
fin.close();
}
void addnewrecord();
void viewrecord();
void updaterecord();
void read();
int get_acctno();
void display();
};
/*
This method is for adding a new account record. The details are added in the dat file accountdets.dat.
*/
void account::addnewrecord()
{
ofstream outfile;
outfile.open("accountdets.dat",ios::out|ios::binary|ios::app);
account person;
cout<<endl<<"Enter first name : ";
gets(person.first_name);
cout<<endl<<"Enter last name : ";
gets(person.last_name);
cout<<endl<<"Enter address : ";
gets(person.address);
cout<<endl<<"Enter city : ";
gets(person.city);
cout<<endl<<"Enter state : ";
gets(person.state);
cout<<endl<<"Enter pin : ";
gets(person.pincode);
cout<<endl<<"Enter phone number : ";
gets(person.phone_number);
cout<<endl<<"Your PERMANENT ACCOUNT NO: is : "<<(acctno++);
cout<<endl<<"\nEnter deposit (min Rs.250) : ";
cin>>person.deposit;
ofstream fout;
fout.open("acctno.dat",ios::out);
fout<<acctno;
fout.close();
outfile.write((char*) &person, sizeof(person));
outfile.close();
}
/*
This method is used for reading the account number input from the user.
*/
void account::read()
{
cout<<"\nEnter the account number : ";
cin>>accno;
}
/*
This method returns the account number that is input by the user.
*/
int account::get_acctno()
{
return accno;
}
/*
This method is used for viewing the account details from the dat file, given a specific account number as input.
*/
void account::viewrecord()
{
ifstream f2;
account t2,t02;
t02.read();
f2.open("accountdets.dat",ios::binary|ios::in);
f2.seekg(0,ios::beg);
int j=0;
while(!f2.eof())
{
f2.read((char*) &t2,sizeof(t2));
if(t2.acctno==t02.get_acctno())
{
j=1;
t2.display();
break;
}
}
if(j!=1)
cout<<"\nRecord not found...";
f2.close();
cout<<"\n\n\t\t\t(Press any key to return to MAIN MENU..)";
getch();
}
/*
This method is used by the viewrecord method to output the specific account record details.
*/
void account::display()
{
cout<<"\n";
cout<<"First name : "<<first_name <<"\n"
<<"Last name : "<<last_name<<"\n"
<<"Address : "<<address<<"\n"
<<"City : "<<city<<"\n"
<<"State : "<<state<<"\n"
<<"Phone Number : "<<phone_number<<"\n"
<<"Deposit : "<<deposit<<"\n";
}
/*
This method is used for updating an account record based on various options.
*/
void account::updaterecord()
{
int ch2,debit,credit;
do{
clrscr();
cout<<"\n\nPlease";
cout<<"\n\tEnter 1 to debit \n"
<<"\tEnter 2 to credit \n"
<<"\tEnter 3 to view account balance \n"
<<"\tEnter 4 to calculate interest and view balance after the calculations\n"
<<"\tEnter 5 to close transactions\n";
cout<<"\nEnter choice : ";
cin>>ch2;
clrscr();
switch(ch2)
{
case 1:
{
fstream f3;
account t3,t03;
int j=0, count=0;
t03.read();
cout<<"\nPlease enter the amount to be debited : ";
cin>>debit;
f3.open("accountdets.dat",ios::binary|ios::in|ios::out);
f3.seekg(0,ios::beg);
while(!f3.eof())
{
f3.read((char*) &t3,sizeof(t3));
if(t3.acctno==t03.get_acctno())
{
j++;
break;
}
count++;
}
if(j!=0)
{
if(debit<=t3.deposit)
{
t3.deposit-=debit;
f3.seekp(count*sizeof(t3),ios::beg);
f3.write((char*) &t3 ,sizeof(t3));
}
if(t3.deposit>=250)
cout<<"Your account balance is Rs"<<t3.deposit;
else
cout<<"Your Balance is not sufficient to debit this amount";
}
else
{
cout<<"\nRecord NOT found";
}
f3.close();
cout<<"\n\n\n\n\t\t(Press any key to return to previous menu..)";
getch();
break;
}//case 1
case 2:
{
fstream f4;
account t4,t04;
int j=0, count=0,credit;
t04.read();
cout<<"\nPlease enter the amount to be credited ";
cin>>credit;
f4.open("accountdets.dat",ios::binary|ios::in|ios::out);
f4.seekg(0,ios::beg);
while(!f4.eof())
{
f4.read((char*) &t4,sizeof(t4));
if(t4.acctno==t04.get_acctno())
{
j++;
break;
}
count++;
}
if(j!=0)
{
t4.deposit+=credit;
f4.seekp(count*sizeof(t4),ios::beg);
f4.write((char*) &t4 ,sizeof(t4));
}
else
{
cout<<"\nRecord NOT found";
}
cout<<"Your account balance is Rs "<<t4.deposit;
f4.close();
cout<<"\n\n\n\n\t\t(Press any key to return to previous menu..)";
getch();
break;
}//case 2
case 3:
{
fstream f6;
account t6,t06;
int j=0;
t06.read();
f6.open("accountdets.dat",ios::binary|ios::in|ios::out);
f6.seekg(0,ios::beg);
while(!f6.eof())
{
f6.read((char*) &t6,sizeof(t6));
if(t6.acctno==t06.get_acctno())
{
j++;
break;
}
}
if(j!=0)
{
cout<<"\n\nThe ACCOUNT BALANCE is Rs "<<t6.deposit;
}
else
{
cout<<"\nRecord NOT found";
}
f6.close();
cout<<"\n\n\n\n\t\t(Press any key to return to previous menu..)";
getch();
break;
}//case 3
case 4:
{
fstream f5;
account t5,t05;
int timeperiod, j=0;
float interest;
t05.read();
f5.open("accountdets.dat",ios::binary|ios::in|ios::out);
f5.seekg(0,ios::beg);
while(!f5.eof())
{
f5.read((char*) &t5,sizeof(t5));
if(t5.acctno==t05.get_acctno())
{
cout<<"\nPlease enter the time period : ";
cin>>timeperiod;
rate=1.5*timeperiod;
interest=t5.deposit*timeperiod*(rate/100.0);
cout<<"\nInterest is Rs "<<interest;
amount=t5.deposit + interest;
cout<<"\nAmount is Rs "<<amount;
if(amount==0)
cout<<"Sorry!The interest rate for the time period you have entered is not specified";
j=1;
break;
}
}
if(j==0)
cout<<"\nRecord not found";
cout<<"\n\n\n\n\t\t(Press any key to return to previous menu..)";
getch();
break;
}//case 4
case 5:cout<<"\n\n\n\n\n\t\tModifications are SAVED to your account..... ";
cout<<"\n\n\t\t\t(Press any key..)";
getch();
ch2=6;
break;
default:cout<<"\n\n\t\t\tinvalid entry!!!!";
cout<<"\n\n\n\n\t\t(Press any key to return to previous menu..)";
getch();
break;
}//switch ch2
}while(ch2<6);
}//updaterecord
void main()
{
password();
char crep,cstr[20];
int irep;
l:clrscr();
cout<<"\nDo you want to change the USERNAME or PASSWORD (y/n) : ";
cin>>crep;
if(crep=='y' || crep=='Y')
{
ofstream of;
cout<<"\nEnter 1 to change username or 2 to change password\n";
cin>>irep;
switch(irep)
{
case 1:
of.open("username.dat",ios::binary|ios::out);
cout<<"\nEnter new Username : ";
gets(cstr);
of.write((char*) &cstr,sizeof(cstr));
of.close();
break;
case 2:
of.open("password.dat",ios::binary|ios::out);
cout<<"\nEnter new password : ";
gets(cstr);
of.write((char*) &cstr,sizeof(cstr));
of.close();
break;
default:
goto l;
}
}
account obj;
int ch;
do
{
clrscr();
cout<<"\n\t\t\t ==========================";
cout<<"\n\t\t\t\t MAIN MENU";
cout<<"\n\t\t\t ==========================\n";
cout<<"\t1. Add record\n";
cout<<"\t2. View record\n";
cout<<"\t3. Update record / Transactions\n";
cout<<"\t4. Exit\n";
cout<<"\tEnter your choice: ";
cin>>ch;
clrscr();
int in=0;
switch(ch)
{
case 1:
obj.addnewrecord();
break;
case 2:
obj.viewrecord();
break;
case 3:
obj.updaterecord();
break;
case 4:
clrscr();
cout<<"\n\n\n\n\n\t\t\tSaving Your Settings";
for(in=0;in<6;in++)
{cout<<'.';delay(1500);}
clrscr();
cout<<"\n\n\n\n\n\t\t\t....Terminating....";
delay(2500);
exit(0);
default:
cout<<"\n\t\t\tinvalid entry!!!!";
cout<<"\n\n\t\t\t(Press any key..)";
getch();
break;
}
}while(ch<10);
}