language: C++ 4.7.2 (gcc-4.7.2)
date: 149 days 9 hours ago
link:
visibility: public
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
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
#include <iostream>
#include <string>
#include <fstream>
#include <conio.h>
#include <sstream>
using namespace std;
//struct lol{
//
//int pass;
//string user;
//
//};
//int main()
//{
//    lol clints[100];
//      cin>>clints[0].pass;
//      cin>>clint1[0].user;
//      int arr[100];
//
//}
string fname,lname,address,telephone,mobile,email,password="",repassword;
string naddress,ntelephone,nmobile,nemail,npassword,nrepassword;
int balancee=0,id=rand();
void firstname()
{
    char ch;
        do 
        {
                cout<<"Please enter your first name"<<endl;
                getline(cin,fname);
                ch=' ';
                for(int i=0 ; i<fname.size() ; i++)
                {
                        if(i==fname.size()-1);
                        break;
                        if(fname[i+1]<'a' || fname[i+1]>'z' || fname[0]<'A' || fname[0]>'Z')
                        {
                                cout<<"Please enter a valid name."<<endl;
                                cout<<"Press y to contniue."<<endl;
                                cin>>ch;
                                cin.ignore();
                                break;
                        }
                }
        }while(ch=='y');
}
 
void lastname()
{
        char ch;
        do
        {
                cout<<"Please enter your last name"<<endl;
                getline(cin,lname);
                ch=' ';
                for(int i=0 ; i<lname.size() ; i++)
                {
                        if(i==lname.size()-1);
                        break;
                        if(lname[i+1]<'a' || lname[i+1]>'z' || lname[0]<'A' || lname[0]>'Z')
                        {
                                cout<<"Please enter a valid name."<<endl;
                                cout<<"Press y to contniue."<<endl;
                                cin>>ch;
                                cin.ignore();
                        }
                }
        }while(ch=='y');
}
 
void telephonenum()
{
        char ch;
        do
        {
                cout<<"Please enter your telephone number."<<endl;
                getline(cin,telephone);
                ch=' ';
                for(int i=0 ; i<telephone.size() ; i++)
                {
                        if(telephone.size()!=8 || telephone[i]<'0' || telephone[i]>'9')
                        {
                                cout<<"Please enter a valid telephone number."<<endl;
                                cout<<"Press y to contniue."<<endl;
                                cin>>ch;
                                cin.ignore();
                                break;
                        }
                }
        }while(ch=='y');
}
 
void mobilenum()
{
        char ch;
        do
        {
                cout<<"Please enter your mobile number."<<endl;
                getline(cin,mobile);
                ch=' ';
                for(int i=0 ; i<mobile.size() ; i++)
                {
                        if(mobile.size()!=11 || mobile[i]<'0' || mobile[i]>'9')
                        {
                                cout<<"Please enter a valid telephone number."<<endl;
                                cout<<"Press y to contniue."<<endl;
                                cin>>ch;
                                cin.ignore();
                                break;
                        }
                }
        }while(ch=='y');
}
 
void deposite()
{
        char ch;
        int money;
        do
        {
                cout<<"Your balance is "<<balancee<<endl;
                cout<<"Please enter an amount of money to be deposited"<<endl;
                cin>>money;
                balancee+=money;
                cout<<"Your balance is "<<balancee<<endl;
                cout<<"If you want to deposite again,press y"<<endl;
                cin>>ch;
        }while(ch=='y');
 
}
 
void withdraw()
{
        char ch;
        int money;
        do
        {
                cout<<"Your balance is "<<balancee<<endl;
                cout<<"Please enter an amount of money to be withdrawn"<<endl;
                cin>>money;
                if(balancee>money && money>0)
                {
                        balancee-=money;
                        cout<<"Your balance is "<<balancee<<endl;
                }
                else
                {
                        cout<<"Your balance is not enough..Please enter a valid amount"<<endl;
                }
                cout<<"If you want to withdraw again,press y"<<endl;
                cin>>ch;
        }while(ch=='y');
}
 
void balance()
{
        char ch;
        do
        {
                cout<<"Your balance is "<<balancee<<endl;
                cout<<"If you want to see your balance again,press y"<<endl;
                cin>>ch;
        }while(ch=='y');
}
 
 
void eaddress()
{
        char ch;
        do
        {
                cout<<"Please enter your new address."<<endl;
                getline(cin,naddress);
                ch=' ';
                address=naddress;
                cout<<"If you want modify again press y"<<endl;
                cin>>ch;
                cin.ignore();
        }while(ch=='y');
}
 
void etelephone()
{
        char ch;
        do
        {
                cout<<"Please enter your new telephone number."<<endl;
                getline(cin,ntelephone);
                ch=' ';
                for(int i=0 ; i<ntelephone.size() ; i++)
                {
                        if(ntelephone.size()!=8 || ntelephone[i]<'0' || ntelephone[i]>'9')
                        {
                                cout<<"Please enter a valid telephone number."<<endl;
                                break;
                        }
                        else
                        {
                                telephone=ntelephone;
                                break;
                        }
                }
                cout<<"If you want modify again press y"<<endl;
                cin>>ch;
                cin.ignore();
        }while(ch=='y');
}
 
void emobile()
{
        char ch;
        do
        {
                cout<<"Please enter your new mobile number."<<endl;
                getline(cin,nmobile);
                ch=' ';
                for(int i=0 ; i<nmobile.size() ; i++)
                {
                        if(nmobile.size()!=11 || nmobile[i]<'0' || nmobile[i]>'9')
                        {
                                cout<<"Please enter a valid mobile number."<<endl;
                                break;
                        }
                        else
                        {
                                mobile=nmobile;
                                break;
                        }
                }
                cout<<"If you want modify again press y"<<endl;
                cin>>ch;
                cin.ignore();
        }while(ch=='y');
}
 
void eemail()
{
        char ch;
        do
        {
                cout<<"Please enter your new e-mail."<<endl;
                getline(cin,nemail);
                ch=' ';
                email=nemail;
                cout<<"If you want modify again press y"<<endl;
                cin>>ch;
                cin.ignore();
        }while(ch=='y');
}
 
void epassword()
{
        char ch1;
        do
        {
                char ch2;
                do
                {
                        cout<<"Please enter your new password."<<endl;
                        getline(cin,npassword);
                        ch2=' ';
                        cout<<"Please re-enter your password"<<endl;
                        getline(cin,nrepassword);
                        if(npassword==nrepassword)
                        {
                                password=npassword;
                        }
                        else
                        {
                                cout<<"The passwords are not identical..Please try again"<<endl;
                                cout<<"Press y to re-type again"<<endl;
                                cin>>ch2;
                                cin.ignore();
                        }
                }while(ch2=='y');
                cout<<"If you want modify again press y"<<endl;
                cin>>ch1;
                cin.ignore();
        }while(ch1=='y');
}
 
void edit()
{
        char ch=' ';
        do
        {
                int choice;
                cout<<"What information would you like to edit ?"<<endl;
                cout<<"1-Address."<<endl;
                cout<<"2-Telephone."<<endl;
                cout<<"3-Mobile."<<endl;
                cout<<"4-E-mail."<<endl;
                cout<<"5-Password."<<endl;
                cin>>choice;
                switch (choice)
                {
                case 1:
                        eaddress();
                        break;
                case 2:
                        etelephone();
                        break;
                case 3:
                        emobile();
                        break;
                case 4:
                        eemail();
                        break;
                case 5:
                        epassword();
                        break;
                default:
                        cout<<"Please enter a valid option."<<endl;
                        break;
                }
                cout<<"If you want to edit again,please enter y"<<endl;
                cin>>ch;
        }while(ch=='y');
}
 
int save()
{
        string line1,line2,line;
        ifstream myfile("1.txt");
        myfile.is_open();
        for(int i=0 ; i<2 ; i++)
                {
                        getline(myfile,line);
                }
        while(myfile.good())
        {
                getline(myfile,line1);
                if(line1==fname)
                {
                        getline(myfile,line2);
                        if(line2==lname)
                        {
                                ofstream myfile ("1.txt");
                                myfile.is_open();
                                myfile<<id<<endl<<password<<endl<<fname<<endl<<lname<<endl<<address<<endl;
                                myfile<<telephone<<endl<<mobile<<endl<<email<<endl<<balancee<<endl;
                                myfile.close();
                                return 0;
                        }
                }
                else
                {
                        if(myfile.good())
                        {
                                for(int i=0 ; i<8 ; i++)
                                {
                                        getline(myfile,line);
                                }
                                continue;
                        }
                        else
                        {
                                ofstream myfile ("1.txt",ios::app);
                                myfile.is_open();
                                myfile<<id<<endl<<password<<endl<<fname<<endl<<lname<<endl<<address<<endl;
                                myfile<<telephone<<endl<<mobile<<endl<<email<<endl<<balancee<<endl;
                                myfile.close();
                                return 0;
                        }
                }
        }
        while(!myfile.good())
        {
                ofstream myfile ("1.txt",ios::app);
                myfile.is_open();
                myfile<<id<<endl<<password<<endl<<fname<<endl<<lname<<endl<<address<<endl;
                myfile<<telephone<<endl<<mobile<<endl<<email<<endl<<balancee<<endl;
                myfile.close();
                break;
        }
        return 0;
}
 
void menu()
{
        char ch=' ';
        do
        {
                cout<<"Please choose one of these operations."<<endl;
                cout<<"1-Deposite Money."<<endl;
                cout<<"2-Withdraw Money."<<endl;
                cout<<"3-Show Your Balance."<<endl;
                cout<<"4-Edit your information"<<endl;
                cout<<"Press the number of the wanted operation."<<endl;
                int choice;
                cin>>choice;
                switch (choice)
                {
                case 1:
                        deposite();
                        break;
                case 2:
                        withdraw();
                        break;
                case 3:
                        balance();
                        break;
                case 4:
                        edit();
                        break;
                default:
                        save();
                        break;
                }
                cout<<"If you want another operation press y."<<endl;
                cin>>ch;
                if(ch!='y')
                        save();
        }while(ch=='y');
}
 
void registeration()
{
        cin.ignore();
        firstname();
        lastname();
        cout<<"Please enter you address."<<endl;
        getline(cin,address);
        telephonenum();
        mobilenum();
        cout<<"Please enter you e-mail."<<endl;
        getline(cin,email);
        cout<<"Your account ID is "<<id<<endl;
        char ch=' ';
        do
        {
                cout<<"Please enter a password to be saved for your account."<<endl;
                getline(cin,password);
                cout<<"Please re-type your password."<<endl;
                getline(cin,repassword);
                if(password==repassword)
                {
                        cout<<"Congratulations!..You have successfully created your account."<<endl;
                        cout<<"If you want to proceed press 1"<<endl;
                        cout<<"Or save your data by pressing 2"<<endl;
                        int choice;
                        cin>>choice;// to enter his choice
                        if(choice==1)
                        {
                                menu();
                        }
                        else if(choice==2)
                        {
                                save();
                        }
                }
                else
                {
                        cout<<"The passwords are not identical..Please try again."<<endl;
                        cout<<"Press y to retype."<<endl;
                        cin>>ch;
                        cin.ignore();
                }
 
        }while(ch=='y');
}
 
void load()
{
        cin.ignore();
        int lid;
        string lpassword;
        string line1,line2,line;
        string lfname,llname,laddress,ltelephone,lmobile,lemail,lbalance;
        char ch=' ';
        do
        {
                cout<<"Please enter you ID"<<endl;
                cin>>lid;
                cin.ignore();
                cout<<"Please enter your password"<<endl;
                getline(cin,lpassword);
                ifstream myfile("1.txt");
                myfile.is_open();
                while(myfile.good())
                {
                        getline(myfile,line1);
                        stringstream convert1(line1);
                        int res;
                        if(!(convert1>>res))
                                res=0;
                        if(lid==res)
                        {
                                getline(myfile,line2);
                                if(lpassword==line2)
                                {
                                        id=lid;
                                        password=lpassword;
                                        getline(myfile,lfname);
                                        fname=lfname;
                                        getline(myfile,llname);
                                        lname=llname;
                                        getline(myfile,laddress);
                                        address=laddress;
                                        getline(myfile,ltelephone);
                                        telephone=ltelephone;
                                        getline(myfile,lmobile);
                                        mobile=lmobile;
                                        getline(myfile,lemail);
                                        email=lemail;
                                        getline(myfile,lbalance);
                                        stringstream convert(lbalance);
                                        if(!(convert>>balancee))
                                                balancee=0;
                                        ch=' ';
                                        cout<<"If you want to proceed press 1."<<endl;
                                        cout<<"Or press 2 to save your data."<<endl;
                                        int choice;
                                        cin>>choice;
                                        if(choice==1)
                                        {
                                                menu();
                                                break;
                                        }
                                        else if(choice==2)
                                        {
                                                save();
                                                break;
                                        }
 
                                }
                                else
                                {
                                        
                                        cout<<"Your ID is invlaid..Press y to try again."<<endl;
                                        cin>>ch;
                                        cin.ignore();
                                        break;
                                }
                        }
                        else
                        {
                                if(myfile.good())
                                {
                                        for(int i=0 ; i<8 ; i++)
                                        {
                                                getline(myfile,line);
                                        }
                                        continue;
                                }
                                else
                                {       
                                        cout<<"Your ID is invlaid..Press y to try again."<<endl;
                                        cin>>ch;
                                        cin.ignore();
                                        break;
                                }
 
                        }
                }
        }while(ch=='y');
}
 
int main ()
{
        system("Color 1A");
        char ch=' ';
        do
        {
                cout<<"Welcome to BANQUE DE LA FCIS!"<<endl;
                cout<<"If you are a new client press 1."<<endl;
                cout<<"If you already have an account in the bank press 2."<<endl;
                int choice;
                cin>>choice; // to identify which he/she is a new client or an existing client
                if(choice==1)// if he/she is a new client
                {
                        registeration();
                }
                else if(choice==2)// if he/she is an existing user
                {
                        load();
                }
                else
                {
                        cout<<"Error..Please select a valid option."<<endl;
                        cout<<"Press y to continue"<<endl;
                        cin>>ch;
                }
        }while(ch=='y');
        return 0;
}
prog.cpp:4:19: error: conio.h: No such file or directory
prog.cpp:23: error: ‘rand’ was not declared in this scope
prog.cpp: In function ‘void firstname()’:
prog.cpp:32: warning: comparison between signed and unsigned integer expressions
prog.cpp:34: warning: comparison between signed and unsigned integer expressions
prog.cpp: In function ‘void lastname()’:
prog.cpp:56: warning: comparison between signed and unsigned integer expressions
prog.cpp:58: warning: comparison between signed and unsigned integer expressions
prog.cpp: In function ‘void telephonenum()’:
prog.cpp:79: warning: comparison between signed and unsigned integer expressions
prog.cpp: In function ‘void mobilenum()’:
prog.cpp:101: warning: comparison between signed and unsigned integer expressions
prog.cpp: In function ‘void etelephone()’:
prog.cpp:190: warning: comparison between signed and unsigned integer expressions
prog.cpp: In function ‘void emobile()’:
prog.cpp:217: warning: comparison between signed and unsigned integer expressions
prog.cpp: In function ‘int main()’:
prog.cpp:561: error: ‘system’ was not declared in this scope