-
Notifications
You must be signed in to change notification settings - Fork 0
/
bnkmgt.c
3174 lines (1721 loc) · 63.2 KB
/
bnkmgt.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
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
#include<conio.h>
#include<time.h>
#include<math.h>
void gotoxy(int x,int y);
void _password(char buffer[]);
void rectangle(int x,int y,int l,int b);
void cls(int x1,int y1,int x2, int y2);
void increase(char i_id[]);
void date_input(char date[]);
void date_output(char date[]);
void currency(char cur[], float n);
void num2word(double n,char word[]);
void _one(int n, char one[]);
void _ten(int n,char ten[]);
int date_check(char date[]);
void title();
void welcome();
void admin();
void add_user();
void del_user();
void edit_user();
void view_log();
void staff();
void uptodate();
void add_ac();
void deposit();
void withdraw();
void fund_transfer();
void ac_info();
void transaction();
void Home();
char date[13],ttime[10];
FILE *fp,*fp1,*tfp;
struct//Structure for storing User information
{
char uid[4];
char name[30], password[30];
} user;
struct account//Structure for storing account information
{
char ac_no[8];
char fname[30], lname[30];
char u_date[15];
char dob[12];
char sex[6];
char address[50],contact[20];
char ac_type;
float c_bal,interest,t_bal;
};
struct trans//Structure for storing transaction information
{
char ac_no[8],ac_t[25],_date[15],_ttime[10],usr[30];
float amt;
};
typedef struct//Structure for storing user log information
{
char id[4];
char name[30];
char date[15]; //Log in date
char stime[10];// Log in time
char etime[10];// Log out or exit time
}user_log;
int gbl_flag=0;
int main()
{
char c;
Home();
welcome();
do
{
system("cls");
rectangle(8,9,70,17);
gotoxy(10,11); printf("Press A to Log in as ADMINISTRATOR or S to log in as STAFF\n\n\n\t\t\t\t\t");
gotoxy(10,12); printf("(Esc to to quit..)");
c=getche(); //Variable c stores the key pressed by user
if(c=='A'||c=='a')
{
strcpy(user.name,"Admin");
admin();
break;
}
if (c=='S'||c=='s')
{
staff();
break;
}
if (c==27) exit(0);
}while(1); //infinite loop incase any key other than Esc, A, or S is pressed.
return 0;
}
void staff()
{
int i,ch;
char uname[30], pass[30],passwrd[30]={0},id[10],nam[30];
int c=0,cnt=0;
char ex,stime[9],etime[9];
cnt=0;//This variable cnt counts the number of attempts of Log in
do
{
system("cls");
rectangle(10,8,70,15);
gotoxy(7,5);printf("Only THREE attempts shall be allowed to enter username and password.");
gotoxy(23,10); printf("Enter User name : "); scanf("%s",user.name);
gotoxy(23,12); printf("Password : ");
char passwrd[30]={0};//To nullify the string passwrd
_password(passwrd);
strcpy(user.password,passwrd);
cnt++;
if (cnt==3)// when no of attempts exceeds 3
{
title();
gotoxy(25,10); printf("Invalid User name or Password!\a");
gotoxy(22,12);printf("Press ENTER to exit the program...");
getch();
exit(0);
}
c=0;//Counts the no. of user for which the name and password matches
fp=fopen("USER.DAT","r");
while(fscanf(fp,"%s %s %s\n",id,nam,pass)!=EOF)
{
strcpy(nam,strupr(nam));//Changing all strings id, nam, pass into uppercase
strcpy(pass,strupr(pass));
strcpy(user.name,strupr(user.name));
strcpy(user.password,strupr(user.password));
if((strcmp(user.name,nam)==0)&&(strcmp(user.password,pass)==0))//account no is allocated and stored in user.dat
{
c++;
strcpy(user.uid,id);
}
}
fclose(fp);
title();
if (c==0)
{
gotoxy(10,10); printf("Cannot find the given combination of USER NAME and PASSWORD!\a");
getch();
}
else break; //terminates do... while loop if record found
} while(1);
_strtime(stime);
uptodate(); // To update interests
do
{
title();
gotoxy(15,8);printf("1. Create New Account\n");
gotoxy(15,10);printf("2. Cash Deposit");
gotoxy(15,12);printf("3. Cash Withdrawl");
gotoxy(15,14);printf("4. Fund Transfer");
gotoxy(15,16);printf("5. Account information");
gotoxy(45,8);printf("6. Transaction information");
gotoxy(45,10); printf("7. Log out");
gotoxy(45,12);printf("8. Exit");
gotoxy(1,17); for(i=0;i<78;i++) printf("_");
gotoxy(23,19);printf("Press a choice between the range [1-8] ");
switch(getch()-48)
{
case 1:
add_ac();
break;
case 2:
deposit();
break;
case 3:
withdraw();
break;
case 4:
fund_transfer();
break;
case 5:
ac_info();
break;
case 6:
transaction();
break;
case 7:
title();
gotoxy(15,10); printf("Are you sure you want to Log out? <Y/N> : ");
ex=getche();
if (ex=='Y'||ex=='y')
{
_strtime(etime);
fp=fopen("LOG.DAT","a");
fprintf(fp,"%s %s %s %s\n",user.uid,date,stime,etime);
fclose(fp);
staff();
}
break;
case 8:
title();
gotoxy(15,10); printf("Are you sure you want to exit? <Y/N> : ");
ex=getche();
if (ex=='Y'||ex=='y')
{
_strtime(etime);
fp=fopen("LOG.DAT","a");
fprintf(fp,"%s %s %s %s\n",user.uid,date,stime,etime);
fclose(fp);
exit(0);
}
break;
default://when entered characted is not between 1-8
title();
gotoxy(10,10); printf("Your input is out of range! Enter a choice between 1 to 8!");
gotoxy(15,12); printf("Press any key to return to main menu...");
getch();
}
}while(1);//infinite loop to return to main menu after execution of any function
}
void add_ac()
{
struct account ac;//structure variable ac created
char acn[8],curr[35],ch;
int i;
float irate;
fp=fopen("ACCOUNT.DAT","r");
if(fp==NULL) strcpy(ac.ac_no,"AC00001");//for first time started from AC00001
else //otherwise a/c no of last record is accessed and increased by unit value which becomes the new a/c no.
{
while(fscanf(fp,"%s %s %s %s %s %s %s %s %s %f %f %f\n",ac.ac_no,ac.fname,ac.lname,ac.dob,ac.address,ac.contact,ac.sex,ac.u_date,&ac.ac_type,&ac.c_bal,&ac.interest,&ac.t_bal)!=EOF);//note the while statement is terminated without any statement inside it. This helps in geting the last rec. of the data file
increase(ac.ac_no);
}
fclose(fp);
title();
gotoxy(8,8); printf("PERSONAL DETAILS");
gotoxy(7,9); for(i=0;i<18;i++) printf("%c",205);
gotoxy(10,11); printf("Full name : "); scanf("%s",ac.fname); scanf("%s",ac.lname);
gotoxy(10,13); printf("Gender <M/F> : "); scanf("%s",ac.sex);
int temp1,temp2;
do
{
gotoxy(10,15); printf("DOB (dd/mm/yyyy) : "); scanf(" %s",ac.dob);
temp1=(ac.dob[6]-48)*1000+(ac.dob[7]-48)*100+(ac.dob[8]-48)*10+(ac.dob[9]-48);
temp2=2000+(date[6]-48)*10+(date[7]-48);
if(date_check(ac.dob)==0||temp1>temp2)//check DOB format
{
printf("\a");
cls(10,15,60,15);
}
}while(date_check(ac.dob)==0||temp1>temp2);//asks date unless format is correct
_strdate(date);
date_input(ac.dob);
gotoxy(10,17); printf("Address : "); scanf(" %[^\n]s",ac.address);
for(i=0;i<strlen(ac.address);i++)
//replace space by +
if (ac.address[i]==32) ac.address[i]='+';
int err;
do
{
gotoxy(10,19); printf("Contact number : "); scanf(" %s",ac.contact);
err=0;
for(i=0;i<strlen(ac.contact);i++)
if(!((ac.contact[i]>='0'&&ac.contact[i]<='9'||ac.contact[i]=='-'||ac.contact[i]=='+')&&strlen(ac.contact)>=6)) err++;
if (err!=0) {printf("\a"); cls(10,19,70,19);}
} while(err!=0);
title();
gotoxy(8,8); printf("ACCOUNT DETAILS");
gotoxy(7,9); for(i=0;i<17;i++) printf("%c",205);
gotoxy(10,11); printf("A/C number : %s",ac.ac_no);
int flag;
do {
gotoxy(10,13); printf("A/C type <S/C> : "); scanf(" %c",&ac.ac_type);
flag=0;
cls(45,13,78,13); //clears screen partially to display full account type.
if (ac.ac_type=='S'||ac.ac_type=='s')
{
irate=8; //interest rate 8% for saving a/c
gotoxy(45,13); printf("Saving Account");
}
else if (ac.ac_type=='C'||ac.ac_type=='c')
{
irate=4; //interest rate 4% for current saving
gotoxy(45,13); printf("Current Account");
}
else
{
printf("\a");
flag=1;
}
} while(flag==1);
date_output(date);
gotoxy(10,15); printf("Account Opened Date : %s",date);
_strdate(date);
strcpy(ac.u_date,date);
gotoxy(10,17); printf("Interest rate : %.2f%c per annum", irate,37);
do
{
gotoxy(10,19); printf("Opening Balance (in INRs.) : "); scanf("%f",&ac.c_bal);
if (ac.c_bal<0) { printf("\a"); cls(10,19,70,19);}
}while(ac.c_bal<0);
ac.t_bal=ac.c_bal+ac.interest;
ac.interest=0;
title();
gotoxy(3,9); printf("Full name : %s %s",ac.fname,ac.lname);
gotoxy(3,11); printf("Gender <M/F> : %c",ac.sex);
gotoxy(3,13); printf("DOB (mm/dd/yy) : %s",ac.dob);
gotoxy(3,15); printf("Address : ");
for(i=0;i<strlen(ac.address);i++)
if (ac.address[i]=='+') putchar(32);//ascii value for space
else putchar(ac.address[i]);
gotoxy(3,17); printf("Contact number : %s",ac.contact);
gotoxy(43,9); printf("A/C number : %s",ac.ac_no);
gotoxy(43,11); printf("A/C type : ");
if (ac.ac_type=='S'||ac.ac_type=='s') printf("Saving Account");
if (ac.ac_type=='C'||ac.ac_type=='c') printf("Current Saving");
gotoxy(43,13); printf("Current Date : %s",date);
gotoxy(43,15); printf("Interest rate : %.2f%c per annum", irate,37);
currency(curr,ac.c_bal);
gotoxy(43,17); printf("Opening Balance : %s",curr);
gotoxy(2,19); for(i=0;i<75;i++) printf("%c",196);
gotoxy(15,21); printf("Are the informations above all correct? <Y/N> ");
ch=getche();
if (ch=='Y'||ch=='y')//On confirmation, new a/c (in account.dat) + transaction showing "A/C Opened" is added (in transaction.dat)
{
fp=fopen("ACCOUNT.DAT","a");
fp1=fopen("TRANSACTION.DAT","a");
_strtime(ttime);
fprintf(fp1,"%s %s %s %s %.2f %s\n",ac.ac_no,"A/C+Opened",date,ttime,ac.c_bal,user.name);
fprintf(fp,"%s %s %s %s %s %s %c %s %c %.2f %.2f %.2f\n",ac.ac_no,ac.fname,ac.lname,ac.dob,ac.address,ac.contact,ac.sex,ac.u_date,ac.ac_type,ac.c_bal,ac.interest,ac.t_bal);
fclose(fp);
fclose(fp1);
title();
gotoxy(20,10); printf("Record Added Successfully!");
getch();
}
}
void uptodate()
{
struct account ac;
int i,no_of_yr,no_of_month,no_of_days,n1,n2;
float r;
fp=fopen("ACCOUNT.DAT","r");
if (fp!=NULL)//performs every thing only when file exists i.e. only wen pointer is not null
{
fp1=fopen("TEMP.DAT","w");
i=0;
while(fscanf(fp,"%s %s %s %s %s %s %c %s %c %f %f %f\n",ac.ac_no,ac.fname,ac.lname,ac.dob,ac.address,ac.contact,&ac.sex,ac.u_date,&ac.ac_type,&ac.c_bal,&ac.interest,&ac.t_bal)!=EOF)
{
//extracting no of days, months and yr of system date
no_of_yr=(date[6]-48)*10+(date[7]-48);
no_of_month=(date[0]-48)*10+(date[1]-48);
no_of_days=(date[3]-48)*10+(date[4]-48);
n1=no_of_yr*365+no_of_month*30+no_of_days;//n1 is no. of days elapsed
no_of_yr=(ac.u_date[6]-48)*10+(ac.u_date[7]-48);
no_of_month=(ac.u_date[0]-48)*10+(ac.u_date[1]-48);
no_of_days=(ac.u_date[3]-48)*10+(ac.u_date[4]-48);
n2=no_of_yr*365+no_of_month*30+no_of_days;//n2 is no. of days elapsed on last updated date
if (ac.ac_type=='S'||ac.ac_type=='s') r=8.0/365; else r=4.0/365;
ac.t_bal=ac.c_bal*pow((1+r/100),n1-n2);//calculation of compound interest
ac.interest+=ac.t_bal-ac.c_bal;//calculation and addition of interest
ac.t_bal=ac.c_bal+ac.interest;//calculation of total balance
strcpy(ac.u_date,date);
fprintf(fp1,"%s %s %s %s %s %s %c %s %c %.2f %.2f %.2f\n",ac.ac_no,ac.fname,ac.lname,ac.dob,ac.address,ac.contact,ac.sex,ac.u_date,ac.ac_type,ac.c_bal,ac.interest,ac.t_bal);
}
fclose(fp);
fclose(fp1);
system("del ACCOUNT.DAT");
system("ren TEMP.DAT ACCOUNT.DAT");
}
}
void deposit()
{
title();
struct account ac;
char acn[10],curr[35],ch,csh[80],temp[80],nam[35];
int c=0;
float amt;
gotoxy(5,10); printf("Deposit to A/C number : "); scanf("%s",acn);
strcpy(acn,strupr(acn)); //changing a/c no. to uppercase
fp=fopen("ACCOUNT.DAT","r");
while(fscanf(fp,"%s %s %s %s %s %s %c %s %c %f %f %f\n",ac.ac_no,ac.fname,ac.lname,ac.dob,ac.address,ac.contact,&ac.sex,ac.u_date,&ac.ac_type,&ac.c_bal,&ac.interest,&ac.t_bal)!=EOF)
if(strcmp(acn,ac.ac_no)==0) { c++; strcpy(nam,ac.fname); strcat(nam," "); strcat(nam,ac.lname); } //variable c counts if the given a/c no exist in data file or not. also if available, the full name is extracted
fclose(fp);
if(c==0)//c=0 means no given a/c no. in data file
{
title();
gotoxy(20,12); printf("Given A/C number does not exits!");
getch();
return;
}
gotoxy(50,10); printf("[ %s ]",nam);
gotoxy(5,12); printf("Amount to be Deposited (in INRs.) : "); scanf("%f",&amt);
title();
gotoxy(30,10); printf("Confirm Transaction");
currency(curr,amt);
gotoxy(3,12); printf("%s to be deposited in A/C number : %s [ %s ]",curr,acn,nam);
num2word((double)amt,csh);
strcpy(temp,"[In words : ");
strcat(temp,csh);
strcat(temp,"]");
gotoxy(40-strlen(temp)/2,14); puts(temp);
gotoxy(8,17);printf("Are you sure you want to perform this tranasction? <Y/N>");
ch=getche();
if (ch=='Y'||ch=='y')
{
fp=fopen("ACCOUNT.DAT","r");
fp1=fopen("TEMP.DAT","a");
while(fscanf(fp,"%s %s %s %s %s %s %c %s %c %f %f %f\n",ac.ac_no,ac.fname,ac.lname,ac.dob,ac.address,ac.contact,&ac.sex,ac.u_date,&ac.ac_type,&ac.c_bal,&ac.interest,&ac.t_bal)!=EOF)
{
if (strcmp(ac.ac_no,acn)==0) ac.c_bal+=amt;//balance is increased
ac.t_bal=ac.c_bal+ac.interest;
fprintf(fp1,"%s %s %s %s %s %s %c %s %c %.2f %.2f %.2f\n",ac.ac_no,ac.fname,ac.lname,ac.dob,ac.address,ac.contact,ac.sex,ac.u_date,ac.ac_type,ac.c_bal,ac.interest,ac.t_bal);
}
fclose(fp1);
fclose(fp);
system("del ACCOUNT.DAT");
system("ren TEMP.DAT ACCOUNT.DAT");
fp=fopen("TRANSACTION.DAT","a");//transaction is added
_strtime(ttime);
fprintf(fp,"%s %s %s %s %.2f %s\n",acn,"Cash+Deposited",date,ttime,amt,user.name);
fclose(fp);
title();
gotoxy(20,12);printf("Transaction completed successfully!");
getch();
}
}
void withdraw()//exactly similar to deposit. only difference is amount is subtracted.
{
title();
struct account ac;
char acn[10],ch,curr[35],csh[80],temp[80], nam[50];
int c=0;
float amt;
gotoxy(5,10); printf("Withdraw from A/C number : "); scanf("%s",acn);
strcpy(acn,strupr(acn));
fp=fopen("ACCOUNT.DAT","r");
while(fscanf(fp,"%s %s %s %s %s %s %c %s %c %f %f %f\n",ac.ac_no,ac.fname,ac.lname,ac.dob,ac.address,ac.contact,&ac.sex,ac.u_date,&ac.ac_type,&ac.c_bal,&ac.interest,&ac.t_bal)!=EOF)
if(strcmp(acn,ac.ac_no)==0) { c++; strcpy(nam,ac.fname); strcat(nam," "); strcat(nam,ac.lname); }
fclose(fp);
if(c==0)
{
title();
gotoxy(20,12); printf("Given A/C number does not exits!");
getch();
return;
}
gotoxy(50,10); printf("[ %s ]",nam);
gotoxy(5,12); printf("Amount to be Withdrawn (in INRs.) : "); scanf("%f",&amt);
fp=fopen("ACCOUNT.DAT","r");
c=0;
while(fscanf(fp,"%s %s %s %s %s %s %c %s %c %f %f %f\n",ac.ac_no,ac.fname,ac.lname,ac.dob,ac.address,ac.contact,&ac.sex,ac.u_date,&ac.ac_type,&ac.c_bal,&ac.interest,&ac.t_bal)!=EOF)
{
if (strcmp(ac.ac_no,acn)==0&&ac.t_bal<amt)// when given amount is higher than bank balance
{
title();
gotoxy(20,12); printf("Sorry, the current balance is Rs. %.2f only!",ac.t_bal);
gotoxy(25,14); printf("Transaction NOT completed!");
c=1;
getch();
return;
}
}
fclose(fp);
title();
gotoxy(30,10); printf("Confirm Transaction");
currency(curr,amt);
gotoxy(3,12); printf("%s to be Withdrawn from A/C number : %s [%s]",curr,acn,nam);
num2word((double)amt,csh);
strcpy(temp,"[In words : ");
strcat(temp,csh);
strcat(temp,"]");
gotoxy(40-strlen(temp)/2,14); puts(temp);
gotoxy(8,17);printf("Are you sure you want to perform this tranasction? <Y/N>");
ch=getche();
if (ch=='Y'||ch=='y')
{
fp=fopen("ACCOUNT.DAT","r");
fp1=fopen("TEMP.DAT","w");
c=0;
while(fscanf(fp,"%s %s %s %s %s %s %c %s %c %f %f %f\n",ac.ac_no,ac.fname,ac.lname,ac.dob,ac.address,ac.contact,&ac.sex,ac.u_date,&ac.ac_type,&ac.c_bal,&ac.interest,&ac.t_bal)!=EOF)
{
if (strcmp(ac.ac_no,acn)==0) ac.c_bal-=amt;
if (ac.c_bal<0) { ac.interest+=ac.c_bal; ac.c_bal=0; }
ac.t_bal=ac.c_bal+ac.interest;
fprintf(fp1,"%s %s %s %s %s %s %c %s %c %.2f %.2f %.2f\n",ac.ac_no,ac.fname,ac.lname,ac.dob,ac.address,ac.contact,ac.sex,ac.u_date,ac.ac_type,ac.c_bal,ac.interest,ac.t_bal);
}
fclose(fp1);
fclose(fp);
system("del ACCOUNT.DAT");
system("ren TEMP.DAT ACCOUNT.DAT");
fp=fopen("TRANSACTION.DAT","a");
_strtime(ttime);
fprintf(fp,"%s %s %s %s %.2f %s\n",acn,"Cash+Withdrawn",date,ttime,amt,user.name);
fclose(fp);
title();
gotoxy(20,12);printf("Transaction completed successfully!");
getch();
}
}
void fund_transfer()
{
char f_acn[8],t_acn[8],ch,curr[35],rem[25],csh[80]={0},temp[80]={0},fnam[35],tnam[35];
struct account ac;
float amt;
int c=0;
title();
gotoxy(3,8); printf("Transferred from (A/C no. ) : "); scanf("%s",f_acn);
strcpy(f_acn,strupr(f_acn));
fp=fopen("ACCOUNT.DAT","r");
c=0;
while(fscanf(fp,"%s %s %s %s %s %s %c %s %c %f %f %f\n",ac.ac_no,ac.fname,ac.lname,ac.dob,ac.address,ac.contact,&ac.sex,ac.u_date,&ac.ac_type,&ac.c_bal,&ac.interest,&ac.t_bal)!=EOF)
if(strcmp(f_acn,ac.ac_no)==0) { c++; strcpy(fnam,ac.fname); strcat(fnam," "); strcat(fnam,ac.lname); }
fclose(fp);
if (c==0)
{
title();
gotoxy(20,12); printf("Given A/C number does not exits!");
getch();
return;
}
gotoxy(50,8); printf("[ %s ]",fnam);
gotoxy(3,10); printf("Transferred to (A/C no. ) : "); scanf("%s",t_acn);
strcpy(t_acn,strupr(t_acn));
fp=fopen("ACCOUNT.DAT","r");
c=0;
while(fscanf(fp,"%s %s %s %s %s %s %c %s %c %f %f %f\n",ac.ac_no,ac.fname,ac.lname,ac.dob,ac.address,ac.contact,&ac.sex,ac.u_date,&ac.ac_type,&ac.c_bal,&ac.interest,&ac.t_bal)!=EOF)
if(strcmp(t_acn,ac.ac_no)==0) { c++; strcpy(tnam,ac.fname); strcat(tnam," "); strcat(tnam,ac.lname); }
fclose(fp);
if (c==0)
{
title();
gotoxy(20,12); printf("Given A/C number does not exits!");
getch();