-
Notifications
You must be signed in to change notification settings - Fork 0
/
R-MARS.c
948 lines (913 loc) · 33.2 KB
/
R-MARS.c
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
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<windows.h>
int i,j,pintemp;
int main_exit;
void menu();
struct date
{
int month,day,year;
};
struct {
char name[60];
int acc_no,age,pin,rate;
char address[60],phone[10];
char nationality[15];
char acc_type[10];
float amt,loanamt;
struct date dob;
struct date deposit;
struct date withdraw;
}add,upd,check,rem,transaction;
float interest(float t,float amount,int rate)
{
float SI;
SI=(rate*t*amount)/100.0;
return (SI);
}
void fordelay(int j)
{ int i,k;
for(i=0;i<j;i++)
k=i;
}
void new_acc()
{
int choice;
FILE *ptr;
ptr=fopen("record.dat","a+");
account_no:
system("cls");
printf("\t\t\t\xB2\xB2\xB2 ADD RECORD \xB2\xB2\xB2\xB2");
y:
printf("Enter today's date(mm/dd/yyyy):");
scanf("%d/%d/%d",&add.deposit.month,&add.deposit.day,&add.deposit.year);
if(add.deposit.month>12 || add.deposit.month<1||add.deposit.day>31||add.deposit.day<1)
{
printf("Wrong Date try again!\n");
goto y;
}
printf("\nEnter the account number:\n");
scanf("%d",&check.acc_no);
while(fscanf(ptr,"%d %s %d/%d/%d %d %d %s %s %s %s %f %d/%d/%d %f %d\n",&add.acc_no,&add.name,&add.dob.month,&add.dob.day,&add.dob.year,&add.age,&add.pin,&add.address,&add.nationality,&add.phone,&add.acc_type,&add.amt,&add.deposit.month,&add.deposit.day,&add.deposit.year)!=EOF)
{
if (check.acc_no==add.acc_no)
{
printf("Account no. already in use!");
fordelay(1000000000);
goto account_no;
}
}
add.acc_no=check.acc_no;
printf("\nEnter the name:");
scanf("%s",&add.name);
printf("\nEnter the date of birth(mm/dd/yyyy):");
scanf("%d/%d/%d",&add.dob.month,&add.dob.day,&add.dob.year);
printf("\nEnter the age:");
scanf("%d",&add.age);
printf("\nCreate your own secure 4 Digit pin:");
scanf("%d",&add.pin);
printf("\nEnter the address:(please use '-' instead of space if needed)");
scanf("%s",&add.address);
printf("\nEnter the nationality:");
scanf("%s",&add.nationality);
a:
printf("\nEnter the phone number: ");
scanf("%s",&add.phone);
if(strlen(add.phone)!=10)
{
printf("Invalid phone number! Please enter a valid 10 digit phone number\n");
goto a;
}
printf("\nEnter the amount to deposit:$");
scanf("%f",&add.amt);
printf("\nType of account:\n\t#Saving\n\t#Current\n\t#Fixed1(for 1 year)\n\t#Fixed2(for 2 years)\n\t#Fixed3(for 3 years)\n\n\tEnter your choice(name):");
scanf("%s",&add.acc_type);
add.loanamt=0;
add.rate=0;
fprintf(ptr,"%d %s %d/%d/%d %d %d %s %s %s %s %f %d/%d/%d %f %d\n",add.acc_no,add.name,add.dob.month,add.dob.day,add.dob.year,add.age,add.pin,add.address,add.nationality,add.phone,add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
fclose(ptr);
printf("\nAccount created successfully!");
add_invalid:
printf("\n\n\n\t\tEnter 1 to go to the main menu and 0 to exit:");
scanf("%d",&main_exit);
system("cls");
if (main_exit==1)
menu();
else if(main_exit==0)
exit(1);
else
{
printf("\nInvalid!\a");
goto add_invalid;
}
}
void view_list()
{
FILE *view;
view=fopen("record.dat","r");
int test=0;
system("cls");
printf("\nACC. NO.\t\tPHONE\t\t\tADDRESS\t\t\tNAME\n");
while(fscanf(view,"%d %s %d/%d/%d %d %d %s %s %s %s %f %d/%d/%d %f %d",&add.acc_no,&add.name,&add.dob.month,&add.dob.day,&add.dob.year,&add.age,&add.pin,&add.address,&add.nationality,&add.phone,&add.acc_type,&add.amt,&add.deposit.month,&add.deposit.day,&add.deposit.year)!=EOF)
{
printf("\n%d\t\t%s\t\t%s\t\t%s",add.acc_no,add.phone,add.address,add.name);
test++;
}
fclose(view);
if (test==0)
{
system("cls");
printf("\nNO RECORDS!!\n");
}
view_list_invalid:
printf("\n\nEnter 1 to go to the main menu and 0 to exit:");
scanf("%d",&main_exit);
system("cls");
if (main_exit==1)
menu();
else if(main_exit==0)
exit(1);
else
{
printf("\nInvalid!\a");
goto view_list_invalid;
}
}
void edit(void)
{
int choice,test=0;
FILE *old,*newrec;
old=fopen("record.dat","r");
newrec=fopen("new.dat","w");
printf("\nEnter the account no. of the customer whose info you want to change:");
scanf("%d",&upd.acc_no);
while(fscanf(old,"%d %s %d/%d/%d %d %d %s %s %s %s %f %d/%d/%d %f %d",&add.acc_no,&add.name,&add.dob.month,&add.dob.day,&add.dob.year,&add.age,&add.pin,&add.address,&add.nationality,&add.phone,&add.acc_type,&add.amt,&add.deposit.month,&add.deposit.day,&add.deposit.year)!=EOF)
{
if (add.acc_no==upd.acc_no)
{
test=1;
printf("\nWhich information do you want to change?\n1.Address\n2.Phone\n\nEnter your choice(1 for address and 2 for phone):");
scanf("%d",&choice);
system("cls");
if(choice==1)
{
printf("Enter the new address:");
scanf("%s",upd.address);
fprintf(newrec,"%d %s %d/%d/%d %d %d %s %s %s %s %f %d/%d/%d %f %d\n",add.acc_no,add.name,add.dob.month,add.dob.day,add.dob.year,add.age,add.pin,upd.address,add.nationality,add.phone,add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
system("cls");
printf("Changes saved!");
}
else if(choice==2)
{
printf("Enter the new phone number:");
scanf("%s",&upd.phone);
fprintf(newrec,"%d %s %d/%d/%d %d %d %s %s %s %s %f %d/%d/%d %f %d\n",add.acc_no,add.name,add.dob.month,add.dob.day,add.dob.year,add.age,add.pin,add.address,add.nationality,upd.phone,add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
system("cls");
printf("Changes saved!");
}
}
else
fprintf(newrec,"%d %s %d/%d/%d %d %d %s %s %s %s %f %d/%d/%d %f %d\n",add.acc_no,add.name,add.dob.month,add.dob.day,add.dob.year,add.age,add.pin,add.address,add.nationality,add.phone,add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
}
fclose(old);
fclose(newrec);
remove("record.dat");
rename("new.dat","record.dat");
if(test!=1)
{
system("cls");
printf("\nRecord not found!!\a\a\a");
edit_invalid:
printf("\nEnter 0 to try again,1 to return to main menu and 2 to exit:");
scanf("%d",&main_exit);
system("cls");
if (main_exit==1)
menu();
else if (main_exit==2)
exit(1);
else if(main_exit==0)
edit();
else
{
printf("\nInvalid!\a");
goto edit_invalid;
}
}
else
{
printf("\n\n\nEnter 1 to go to the main menu and 0 to exit:");
scanf("%d",&main_exit);
system("cls");
if (main_exit==1)
menu();
else
exit(1);
}
}
void transact(void)
{
int choice,test=0,pin;
FILE *old,*newrec;
old=fopen("record.dat","r");
newrec=fopen("new.dat","w");
printf("Enter the account no. of the customer:");
scanf("%d",&transaction.acc_no);
while (fscanf(old,"%d %s %d/%d/%d %d %d %s %s %s %s %f %d/%d/%d %f %d",&add.acc_no,add.name,&add.dob.month,&add.dob.day,&add.dob.year,&add.age,&add.pin,&add.address,&add.nationality,&add.phone,&add.acc_type,&add.amt,&add.deposit.month,&add.deposit.day,&add.deposit.year)!=EOF)
{
if(add.acc_no==transaction.acc_no)
{
test=1;
if(strcmpi(add.acc_type,"fixed1")==0||strcmpi(add.acc_type,"fixed2")==0||strcmpi(add.acc_type,"fixed3")==0)
{
printf("\a\a\a\n\nYOU CANNOT DEPOSIT OR WITHDRAW CASH IN FIXED ACCOUNTS!!!!!");
fordelay(1000000000);
system("cls");
menu();
}
x:
printf("\n\nDo you want to\n1.Deposit\n2.Withdraw?\n\nEnter your choice(1 for deposit and 2 for withdraw):");
scanf("%d",&choice);
if (choice==1)
{
printf("Enter the amount you want to deposit:$ ");
scanf("%f",&transaction.amt);
add.amt+=transaction.amt;
fprintf(newrec,"%d %s %d/%d/%d %d %d %s %s %s %s %f %d/%d/%d %f %d\n",add.acc_no,add.name,add.dob.month,add.dob.day,add.dob.year,add.age,add.pin,add.address,add.nationality,add.phone,add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
printf("\n\nDeposited successfully!");
}
else if(choice==2)
{
printf("Enter The Pin........");
scanf("%d",&check.pin);
if(add.pin==check.pin)
{
printf("Enter the amount you want to withdraw:$ ");
scanf("%f",&transaction.amt);
add.amt-=transaction.amt;
fprintf(newrec,"%d %s %d/%d/%d %d %d %s %s %s %s %f %d/%d/%d %f %d\n",add.acc_no,add.name,add.dob.month,add.dob.day,add.dob.year,add.age,add.pin,add.address,add.nationality,add.phone,add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
printf("\n\nWithdrawn successfully!");
}
else
{
printf("Wrong pin entered!");
}
}
else
{
printf("Wrong Choice");
goto x;
}
}
else
{
fprintf(newrec,"%d %s %d/%d/%d %d %d %s %s %s %s %f %d/%d/%d %f %d\n",add.acc_no,add.name,add.dob.month,add.dob.day,add.dob.year,add.age,add.pin,add.address,add.nationality,add.phone,add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
}
}
fclose(old);
fclose(newrec);
remove("record.dat");
rename("new.dat","record.dat");
if(test!=1)
{
printf("\n\nRecord not found!!");
transact_invalid:
printf("\n\n\nEnter 0 to try again,1 to return to main menu and 2 to exit:");
scanf("%d",&main_exit);
system("cls");
if (main_exit==0)
transact();
else if (main_exit==1)
menu();
else if (main_exit==2)
exit(1);
else
{
printf("\nInvalid!");
goto transact_invalid;
}
}
else
{
printf("\nEnter 1 to go to the main menu and 0 to exit:");
scanf("%d",&main_exit);
system("cls");
if (main_exit==1)
menu();
else
exit(1);
}
}
void erase(void)
{
FILE *old,*newrec;
int test=0;
old=fopen("record.dat","r");
newrec=fopen("new.dat","w");
printf("Enter the account no. of the customer you want to delete:");
scanf("%d",&rem.acc_no);
while (fscanf(old,"%d %s %d/%d/%d %d %d %s %s %s %s %f %d/%d/%d %f %d",&add.acc_no,&add.name,&add.dob.month,&add.dob.day,&add.dob.year,&add.age,&add.pin,&add.address,&add.nationality,&add.phone,&add.acc_type,&add.amt,&add.deposit.month,&add.deposit.day,&add.deposit.year)!=EOF)
{
if(add.acc_no!=rem.acc_no)
fprintf(newrec,"%d %s %d/%d/%d %d %d %s %s %s %s %f %d/%d/%d %f %d\n",add.acc_no,add.name,add.dob.month,add.dob.day,add.dob.year,add.age,add.pin,add.address,add.nationality,add.phone,add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
else
{
test++;
printf("\nRecord deleted successfully!\n");
}
}
fclose(old);
fclose(newrec);
remove("record.dat");
rename("new.dat","record.dat");
if(test==0)
{
printf("\nRecord not found!!\a\a\a");
erase_invalid:
printf("\nEnter 0 to try again,1 to return to main menu and 2 to exit:");
scanf("%d",&main_exit);
if (main_exit==1)
menu();
else if (main_exit==2)
exit(1);
else if(main_exit==0)
erase();
else
{printf("\nInvalid!\a");
goto erase_invalid;}
}
else
{printf("\nEnter 1 to go to the main menu and 0 to exit:");
scanf("%d",&main_exit);
system("cls");
if (main_exit==1)
menu();
else
exit(1);
}
}
void see(void)
{
FILE *ptr;
int test=0,rate;
int choice;
float time;
float intrst;
ptr=fopen("record.dat","r");
printf("Do you want to check by\n1.Account no\n2.Name\nEnter your choice:");
scanf("%d",&choice);
if (choice==1)
{ printf("Enter the account number:");
scanf("%d",&check.acc_no);
while (fscanf(ptr,"%d %s %d/%d/%d %d %d %s %s %s %s %f %d/%d/%d %f %d",&add.acc_no,add.name,&add.dob.month,&add.dob.day,&add.dob.year,&add.age,&add.pin,&add.address,&add.nationality,&add.phone,&add.acc_type,&add.amt,&add.deposit.month,&add.deposit.day,&add.deposit.year)!=EOF)
{
if(add.acc_no==check.acc_no)
{
system("cls");
test=1;
printf("\nAccount NO.:%d\nName:%s \nDOB:%d/%d/%d \nAge:%d \nAddress:%s \nnationality:%s \nPhone number:%.0s \nType Of Account:%s \nAmount deposited:$ %.2f \nDate Of Deposit:%d/%d/%d\n\n",add.acc_no,add.name,add.dob.month,add.dob.day,add.dob.year,add.age,add.address,add.nationality,add.phone,add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
if(strcmpi(add.acc_type,"fixed1")==0)
{
time=1.0;
rate=9;
intrst=interest(time,add.amt,rate);
printf("You will get $%.2f as interest on %d/%d/%d\n",intrst,add.deposit.month,add.deposit.day,add.deposit.year+1);
sleep(10);
goto see_invalid;
}
else if(strcmpi(add.acc_type,"fixed2")==0)
{
time=2.0;
rate=11;
intrst=interest(time,add.amt,rate);
printf("You will get $%.2f as interest on %d/%d/%d\n",intrst,add.deposit.month,add.deposit.day,add.deposit.year+2);
sleep(10);
goto see_invalid;
}
else if(strcmpi(add.acc_type,"fixed3")==0)
{
time=3.0;
rate=13;
intrst=interest(time,add.amt,rate);
printf("You will get $%.2f as interest on %d/%d/%d\n",intrst,add.deposit.month,add.deposit.day,add.deposit.year+3);
sleep(10);
goto see_invalid;
}
else if(strcmpi(add.acc_type,"saving")==0)
{
time=(1.0/12.0);
rate=8;
intrst=interest(time,add.amt,rate);
printf("You will get $.%.2f as interest on %d of every month\n",intrst,add.deposit.day);
sleep(10);
goto see_invalid;
}
else if(strcmpi(add.acc_type,"current")==0)
{
printf("You will get no interest\a\a\n");
sleep(10);
goto see_invalid;
}
}
}
}
else if (choice==2)
{ printf("Enter the name:\n");
scanf("%s",&check.name);
while (fscanf(ptr,"%d %s %d/%d/%d %d %d %s %s %s %s %f %d/%d/%d %f %d",&add.acc_no,&add.name,&add.dob.month,&add.dob.day,&add.dob.year,&add.age,&add.pin,&add.address,&add.nationality,&add.phone,&add.acc_type,&add.amt,&add.deposit.month,&add.deposit.day,&add.deposit.year)!=EOF)
{
if(strcmpi(add.name,check.name)==0)
{
system("cls");
test=1;
printf("\nAccount No.:%d\nName:%s \nDOB:%d/%d/%d \nAge:%d \nAddress:%s \nnationality No:%s \nPhone number:%.0s \nType Of Account:%s \nAmount deposited:$%.2f \nDate Of Deposit:%d/%d/%d\n\n",add.acc_no,add.name,add.dob.month,add.dob.day,add.dob.year,add.age,add.address,add.nationality,add.phone,add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
if(strcmpi(add.acc_type,"fixed1")==0)
{
time=1.0;
rate=9;
intrst=interest(time,add.amt,rate);
printf("You will get $%.2f as interest on %d/%d/%d\n",intrst,add.deposit.month,add.deposit.day,add.deposit.year+1);
sleep(10);
goto see_invalid;
}
else if(strcmpi(add.acc_type,"fixed2")==0)
{
time=2.0;
rate=11;
intrst=interest(time,add.amt,rate);
printf("You will get $%.2f as interest on %d/%d/%d\n",intrst,add.deposit.month,add.deposit.day,add.deposit.year+2);
sleep(10);
goto see_invalid;
}
else if(strcmpi(add.acc_type,"fixed3")==0)
{
time=3.0;
rate=13;
intrst=interest(time,add.amt,rate);
printf("You will get $%.2f as interest on %d/%d/%d\n",intrst,add.deposit.month,add.deposit.day,add.deposit.year+3);
sleep(10);
goto see_invalid;
}
else if(strcmpi(add.acc_type,"saving")==0)
{
time=(1.0/12.0);
rate=8;
intrst=interest(time,add.amt,rate);
printf("You will get $%.2f as interest on %d of every month\n",intrst,add.deposit.day);
sleep(10);
goto see_invalid;
}
else if(strcmpi(add.acc_type,"current")==0)
{
printf("You will get no interest\a\a\n");
sleep(10);
goto see_invalid;
}
}
}
}
else
{
printf("Wrong choice! choose again\n");
see();
}
fclose(ptr);
if(test!=1)
{
system("cls");
printf("\nRecord not found!!\a\a\a");
see_invalid:
printf("\nEnter 0 to try again,1 to return to main menu and 2 to exit: ");
scanf("%d",&main_exit);
system("cls");
if (main_exit==1)
menu();
else if (main_exit==2)
exit(1);
else if(main_exit==0)
see();
else
{
system("cls");
printf("\nInvalid!\a");
goto see_invalid;
}
}
else
{
printf("\nEnter 1 to go to the main menu and 0 to exit:");
scanf("%d",&main_exit);
}
if (main_exit==1)
{
system("cls");
menu();
}
else
{
system("cls");
exit(1);
}
}
void Loan(void)
{
int i,j,loan_amt,test=0;
FILE *ptr,*newrec;
ptr=fopen("record.dat","r");
newrec=fopen("loan.dat","a");
printf("\nWant a Loan ? , We're here for you...\n");
printf("Select 1 for Home Loan @ 10%\n");
printf("Select 2 for Car Loan @ 10%\n");
printf("Select 3 for Education Loan @ 8%\n");
printf("Select 4 for Personal Loan @ 12%\n");
scanf("%d",&i);
switch(i)
{
case 1:
printf("\n Applying for home loan has never been easier!\n");
printf("Enter your account number\n");
scanf("%d",&check.acc_no);
while (fscanf(ptr,"%d %s %d/%d/%d %d %d %s %s %s %s %f %d/%d/%d",&add.acc_no,add.name,&add.dob.month,&add.dob.day,&add.dob.year,&add.age,&add.pin,&add.address,&add.nationality,&add.phone,&add.acc_type,&add.amt,&add.deposit.month,&add.deposit.day,&add.deposit.year)!=EOF)
{
if(check.acc_no==add.acc_no)
{
test=1;
printf("Enter Your PIN\n");
scanf("%d",&check.pin);
if(check.pin==add.pin)
{
printf("How much loan do you require?\n");
scanf("%d",&loan_amt);
printf("Now we will check for your account information and see if you are allowed to have this much loan\n");
sleep(2);
if(add.amt>=(loan_amt/10.0))
{
printf("You are Eligible to apply for this loan!\n");
printf("Do you want to take the loan?\nPress 1 for Yes and 2 for No\n");
scanf("%d",&j);
switch(j)
{
case 1:
printf("Your loan has been approved !!\n Your rate of interest is 10 percent annually\nKindly Deposit your aadhar card copy and bank statement at front desk and collect loan amount from money counter");
add.loanamt+=loan_amt;
add.rate=10;
fprintf(newrec,"%d %s %d/%d/%d %d %d %s %s %s %s %f %d/%d/%d\n",add.acc_no,add.name,add.dob.month,add.dob.day,add.dob.year,add.age,add.pin,add.address,add.nationality,add.phone,add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
break;
case 2:
printf("Loan cancelled by user");
break;
}
}
else
{
printf("Your current account balance is not enough to apply for a loan of the given amount\n");
}
Loan1_invalid:
printf("\nEnter 0 to apply again,1 to return to main menu and 2 to exit:\n");
scanf("%d",&main_exit);
system("cls");
if (main_exit==1)
menu();
else if (main_exit==2)
exit(1);
else if(main_exit==0)
Loan();
else
{
printf("\nInvalid!\a");
goto Loan1_invalid;
}
}
else
{
printf("Wrong PIN Entered\n");
}
break;
}
}
if(test!=1)
{
printf("\n\nRecord not found!!");
}
goto Loan1_invalid;
break;
case 2:
printf("Applying for car loan has never been easier!\n");
printf("Enter your account number\n");
scanf("%d",&check.acc_no);
while (fscanf(ptr,"%d %s %d/%d/%d %d %d %s %s %s %s %f %d/%d/%d",&add.acc_no,add.name,&add.dob.month,&add.dob.day,&add.dob.year,&add.age,&add.pin,&add.address,&add.nationality,&add.phone,&add.acc_type,&add.amt,&add.deposit.month,&add.deposit.day,&add.deposit.year)!=EOF)
{
if(check.acc_no==add.acc_no)
{
test=1;
printf("Enter Your PIN\n");
scanf("%d",&check.pin);
if(add.pin==check.pin)
{
printf("How much loan do you require?\n");
scanf("%d",&loan_amt);
printf("Now we will check for your account information and see if you are allowed to have this much loan\n");
sleep(2);
if(add.amt>=(loan_amt/10.0))
{
printf("You are Eligible to apply for this loan!\n");
printf("Do you want to take the loan? press 1 for Yes and 2 for No\n");
scanf("%d",&j);
switch(j)
{
case 1:
printf("Your loan has been approved !!\n Your rate of interest is 10 percent annually\nKindly Deposit your aadhar card copy and bank statement at front desk and collect loan amount from money counter\n");
add.loanamt+=loan_amt;
add.rate=10;
fprintf(newrec,"%d %s %d/%d/%d %d %d %s %s %s %s %f %d/%d/%d\n",add.acc_no,add.name,add.dob.month,add.dob.day,add.dob.year,add.age,add.pin,add.address,add.nationality,add.phone,add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
break;
case 2:
printf("Loan cancelled by user\n");
break;
}
}
else
{
printf("Your current account balance is not enough to apply for a loan of the given amount\n");
}
Loan2_invalid:
printf("\nEnter 0 to apply again,1 to return to main menu and 2 to exit:\n");
scanf("%d",&main_exit);
system("cls");
if (main_exit==1)
menu();
else if (main_exit==2)
exit(1);
else if(main_exit==0)
Loan();
else
{
printf("\nInvalid!\a");
goto Loan2_invalid;
}
}
else
{
printf("Wrong PIN Entered");
}
break;
}
}
if(test!=1)
{
printf("\n\nRecord not found!!");
}
goto Loan2_invalid;
break;
case 3:
printf("Applying for Education loan has never been easier!\n");
printf("Enter your account number\n");
scanf("%d",&check.acc_no);
while (fscanf(ptr,"%d %s %d/%d/%d %d %d %s %s %s %s %f %d/%d/%d",&add.acc_no,add.name,&add.dob.month,&add.dob.day,&add.dob.year,&add.age,&add.pin,&add.address,&add.nationality,&add.phone,&add.acc_type,&add.amt,&add.deposit.month,&add.deposit.day,&add.deposit.year)!=EOF)
{
if(check.acc_no==add.acc_no)
{
test=1;
printf("Enter Your PIN\n");
scanf("%d",&check.pin);
if(add.pin==check.pin)
{
printf("How much loan do you require?\n");
scanf("%d",&loan_amt);
printf("Now we will check for your account information and see if you are allowed to have this much loan\n");
sleep(2);
if(add.amt>=(loan_amt/10.0))
{
printf("You are Eligible to apply for this loan!\n");
printf("Do you want to take the loan? press 1 for Yes and 2 for No\n");
scanf("%d",&j);
switch(j)
{
case 1:
printf("Your loan has been approved !!\n Your rate of interest is 8 percent annually\nKindly Deposit your aadhar card copy and bank statement at front desk and collect loan amount from money counter\n");
add.loanamt+=loan_amt;
add.rate=10;
fprintf(newrec,"%d %s %d/%d/%d %d %d %s %s %s %s %f %d/%d/%d\n",add.acc_no,add.name,add.dob.month,add.dob.day,add.dob.year,add.age,add.pin,add.address,add.nationality,add.phone,add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
break;
case 2:
printf("Loan cancelled by user\n");
break;
}
}
else
{
printf("Your current account balance is not enough to apply for a loan of the given amount\n");
}
Loan3_invalid:
printf("\nEnter 0 to apply again,1 to return to main menu and 2 to exit:\n");
scanf("%d",&main_exit);
system("cls");
if (main_exit==1)
menu();
else if (main_exit==2)
exit(1);
else if(main_exit==0)
Loan();
else
{
printf("\nInvalid!\a");
goto Loan3_invalid;
}
}
else
{
printf("Wrong PIN Entered");
}
break;
}
}
if(test!=1)
{
printf("\n\nRecord not found!!");
}
goto Loan3_invalid;
break;
case 4:
printf("Applying for Personal loan has never been easier!\n");
printf("Enter your account number\n");
scanf("%d",&check.acc_no);
while (fscanf(ptr,"%d %s %d/%d/%d %d %d %s %s %s %s %f %d/%d/%d",&add.acc_no,add.name,&add.dob.month,&add.dob.day,&add.dob.year,&add.age,&add.pin,&add.address,&add.nationality,&add.phone,&add.acc_type,&add.amt,&add.deposit.month,&add.deposit.day,&add.deposit.year)!=EOF)
{
if(check.acc_no==add.acc_no)
{
test=1;
printf("Enter Your PIN\n");
scanf("%d",&check.pin);
if(add.pin==check.pin)
{
printf("How much loan do you require?\n");
scanf("%d",&loan_amt);
printf("Now we will check for your account information and see if you are allowed to have this much loan\n");
sleep(2);
if(add.amt>=(loan_amt/10.0))
{
printf("You are Eligible to apply for this loan!\n");
printf("Do you want to take the loan? press 1 for Yes and 2 for No\n");
scanf("%d",&j);
switch(j)
{
case 1:
printf("Your loan has been approved !!\n Your rate of interest is 12 percent annually\nKindly Deposit your aadhar card copy and bank statement at front desk and collect loan amount from money counter\n");
add.loanamt+=loan_amt;
add.rate=10;
fprintf(newrec,"%d %s %d/%d/%d %d %d %s %s %s %s %f %d/%d/%d\n",add.acc_no,add.name,add.dob.month,add.dob.day,add.dob.year,add.age,add.pin,add.address,add.nationality,add.phone,add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
break;
case 2:
printf("Loan cancelled by user\n");
break;
}
}
else
{
printf("Your current account balance is not enough to apply for a loan of the given amount\n");
}
Loan4_invalid:
printf("\nEnter 0 to apply again,1 to return to main menu and 2 to exit:\n");
scanf("%d",&main_exit);
system("cls");
if (main_exit==1)
menu();
else if (main_exit==2)
exit(1);
else if(main_exit==0)
Loan();
else
{
printf("\nInvalid!\a");
goto Loan4_invalid;
}
}
else
{
printf("Wrong PIN Entered\n");
}
break;
}
}
if(test!=1)
{
printf("\n\nRecord not found!!");
}
goto Loan4_invalid;
break;
default:
{
printf("Wrong choice entered\n");
Loan5_invalid:
printf("\nEnter 0 to apply again,1 to return to main menu and 2 to exit:\n");
scanf("%d",&main_exit);
system("cls");
if (main_exit==1)
menu();
else if (main_exit==2)
exit(1);
else if(main_exit==0)
Loan();
else
{
printf("\nInvalid!\a");
goto Loan5_invalid;
}
break;
}
}
fclose(ptr);
fclose(newrec);
}
void debitcard(void)
{
FILE *debit;
int test=0;
debit=fopen("record.dat","r");
printf("Enter the Account no. of DEBIT CARD applicant:\n");
scanf("%d",&check.acc_no);
while (fscanf(debit,"%d %s %d/%d/%d %d %d %s %s %s %s %f %d/%d/%d\n",&add.acc_no,add.name,&add.dob.month,&add.dob.day,&add.dob.year,&add.age,&add.pin,&add.address,&add.nationality,&add.phone,&add.acc_type,&add.amt,&add.deposit.month,&add.deposit.day,&add.deposit.year)!=EOF)
{
if(check.acc_no==add.acc_no)
{
test=1;
printf("Enter Your PIN\n");
scanf("%d",&check.pin);
if(check.pin==add.pin)
{
printf("Your request have been accepted,contact Helpdesk for PIN when you recieve the DEBIT CARD.\n");
}
else
{
printf("Wrong pin entered\n");
goto debit_invalid;
}
}
}
if(test==0)
{
printf("Record not found!!\n");
}
debit_invalid:
printf("\nEnter 0 to apply again,1 to return to main menu and 2 to exit:\n");
scanf("%d",&main_exit);
system("cls");
if (main_exit==1)
menu();
else if (main_exit==2)
exit(1);
else if(main_exit==0)
debitcard();
else
{
printf("\nInvalid!\a");
goto debit_invalid;
}
fclose(debit);
}
void menu(void)
{
int choice;
system("cls");
system("color 5");
printf("\n\n\t\t\tR-MARS Banking Solutions");
printf("\n\n\n\t\t\t\xB2\xB2\xB2\xB2\xB2\xB2\xB2 WELCOME TO THE MAIN MENU \xB2\xB2\xB2\xB2\xB2\xB2\xB2");
printf("\n\n\t\t1.Create new account\n\t\t2.Modify Account Details\n\t\t3.Make your transactions\n\t\t4.Account's Enquiry\n\t\t5.Account Closure\n\t\t6.View customer's list\n\t\t7.Apply for Loan\n\t\t8.Apply for Debitcard\n\t\t9.Exit\n\n\n\n\n\t\t Enter your choice:");
scanf("%d",&choice);
system("cls");
switch(choice)
{
case 1:
new_acc();
break;
case 2:
edit();
break;
case 3:
transact();
break;
case 4:
see();
break;
case 5:
erase();
break;
case 6:
view_list();
break;
case 7:
Loan();
break;
case 8:
debitcard();
break;
case 9:
exit(1);
break;
}
}
int main()
{
menu();
return 0;
}