-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinvschool.c
958 lines (902 loc) · 29.5 KB
/
invschool.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
//School Invoicing System
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<conio.h>
#include<windows.h>
struct dat//for date(month and day
{
int d,m;//d=day,m=month
};
int clscanf();//check class (1-12)
struct student
{
struct dat dt;
float f,fine,tot,adv,due;//f=fee
char n[50];
int r,c;//roll and class
} stud,s;
struct teacher
{
struct dat dt;
char n[50];
float sal,adv,tot;
int id,no;
} tech,t;
int chkdat(int,int);// for checking date
void addrec(int);//for adding records
void modrec(int);//for modifying records
void searchrec(int);//for searching records
void delrec(int);//for deleting records
void salary(int);//for the calculation of salary of teacher and staff
FILE *fs,*ft;//file declaration
int mm,dd;//mm=month, dd=day
void ext();//for exiting
void main(void)
{
int i,j,k;
for(i=0; i<80; i++)
{
printf("\xdb");
}
printf("\n");
for(i=0; i<80; i++)
{
printf("\xdb");
}
system("color 9a");
printf(" \t_______________________________________________________\n");
printf("\t| |\n");
printf("\t|**WELCOME TO C PROGRAM INVOICING SYSTEM SCHOOL PROJECT|**\n");
printf("\n\t| |\n");
printf("\t ______________________________________________________\n");
printf("\t| ***************************************** |\n");
printf("\t| ***************************************** |\n");
printf(" \t_______________________________________________________\n");
printf("\n\tPLEASE ENTER ANY KEY TO CONTINUE");
for(i=0; i<5; i++)
{
printf(".");
Sleep(500);//after printing one . another comes after 0.5 seconds
}
getch();
system("cls");//clears the screen
printf("\n");
for(i=0; i<80; i++)
{
printf("\xdb");
}
system("color 6b");
printf("\n\n\t** WELCOME TO C PROGRAM INVOICING SYSTEM FOR SCHOOL **\n\n\n");
for(i=0; i<80; i++)
{
printf("\xdb");
}
printf("\nPLEASE ENTER ANY KEY TO START\n");
for(i=0; i<5; i++)
{
printf(".");
Sleep(500);
}
fflush(stdin);
getch();
system("cls");
system("color 0f");//1st is for back ground color and second is for text color
printf("\n\t\tPLEASE ENTER CURRENT DATE\nmm dd\n ");
scanf("%d%d",&mm,&dd);
mm=chkdat(mm,dd);
start();
}
void start()
{
int i,j;//j is for selection of account type
system("cls");
printf("\n\t\tPLEASE ENTER ACCOUNT TYPE");
printf("\n\t\t1:: Student");
printf("\n\t\t2:: Teachers and Staffs");
printf("\n\t\t3:: Exit");
printf("\n\t\tAccount type choice ");
fflush(stdin);
scanf("%d",&j);
switch (j)
{
case 3:
ext();
case 1:
{
system("cls");
printf("\n\t\tPLEASE ENTER THE CHOICE");
printf("\n\t\t1:: Add record");
printf("\n\t\t2:: Search record");
printf("\n\t\t3:: Modify record");
printf("\n\t\t4:: Delete record");
printf("\n\t\t5:: Calculate fee");
printf("\n\t\t6:: Exit");
printf("\n\n Enter choice ");
fflush(stdin);
scanf("%d",&i);
switch (i)
{
case 1:
addrec(j);//function call
start();//function call
case 2:
searchrec(j);
start();
case 3:
modrec(j);
start();
case 4:
delrec(j);
start();
case 5:
fee(mm);
start();
case 6:
ext();
default :
{
printf("\n\n\tInvalid entry!!");
printf("\n\nTo Account Type\n\n\t");
system("pause");
start();
}
}
}
case 2:
{
system("cls");
printf("\n\t\tPLEASE ENTER THE CHOICE");
printf("\n\t\t1:: Add record");
printf("\n\t\t2:: Search record");
printf("\n\t\t3:: Modify record");
printf("\n\t\t4:: Delete record");
printf("\n\t\t5:: Calculate Salary");
printf("\n\t\t6:: Exit");
printf("\n\n Enter choice ");
fflush(stdin);
scanf("%d",&i);
switch (i)
{
case 1:
addrec(j);
start();
case 2:
searchrec(j);
start();
case 3:
modrec(j);
start();
case 4:
delrec(j);
case 5:
salary(mm);
start();
case 6:
ext();
default :
{
printf("\n\n\tInvalid entry!!");
printf("\n\nTo Account Type\n\n\t");
system("pause");
start();
}
}
}
default :
{
printf("\n\n\tInvalid entry!!");
printf("\n\nTo Account Type\n\n\t");
system("pause");
start();
}
}
}
void addrec(int j)
{
int dif,cdat,ddat,month=0;//cdat=month till which fee is cleared
float ff;//used in calculatin of fee of different class
char c='y';
system("cls");
printf("\n\t******************************************************************");
printf("\n\t *************************** ");
printf("\n\t********************* ADD RECORD *******************");
printf("\n\t *************************** ");
printf("\n\t******************************************************************");
if (j==1)
{
while(c=='y'||c=='Y')
{
int a=1;
printf("\n\nEnter the name of student: ");
fflush(stdin);
scanf("%[^\n]",stud.n);
printf("\nEnter the class: ");
fflush(stdin);
stud.c=clscanf();
printf("\nEnter the Roll No.:");
fflush(stdin);
scanf("%2d",&stud.r);
printf("\nEnter month and day till which fee is paid:");
fflush(stdin);
scanf("%2d%2d",&cdat,&ddat);
cdat=chkdat(cdat,ddat);
stud.dt.m=cdat;
ff=stud.c/10.0;
stud.f=1000*(1+ff);//fee of different classes
dif=mm-stud.dt.m;//months of fee left to be paid
stud.fine=(dif*stud.f)*1/100;
stud.due=(dif)*stud.f;//fees left to be paid
if(dif==1)
{
stud.tot=stud.f;
stud.fine=0;
}
else
{
stud.tot=stud.fine+stud.due;
}//for calculation of total fee
fs=fopen("student","ab+");//opening a binary file in apend mode
fwrite(&stud,sizeof(stud),1,fs);
fclose(fs);
printf("\n\nDo you want to continue with the process(press y or Y");
fflush(stdin);
c=getch();
}
getch();
}
if (j==2)
{
while(c=='y'||c=='Y')
{
int a=1;
printf("\n\nEnter name of teacher/staff:" );
fflush(stdin);
scanf("%[^\n]",tech.n);
printf("\nEnter teacher/staff id: ");
fflush(stdin);
scanf("%d",&tech.id);
printf("\nEnter number of class/shift per month:: ");
scanf("%d",&tech.no);
fflush(stdin);
printf("\nEnter month and day till which salary is paid::");
scanf("%d %d",&tech.dt.m,&tech.dt.d);
cdat=chkdat(cdat,ddat);
tech.dt.m=cdat;
tech.sal=tech.no*500;
tech.adv=(tech.dt.m-mm-1)*tech.sal;
if (tech.adv<0) tech.adv=0;
tech.tot=tech.sal;
ft=fopen("teacher","ab+");
fwrite(&tech,sizeof(tech),1,ft);
fclose(ft);
printf("\n\nDo you want to continue with the process(press y or Y");
fflush(stdin);
c=getch();
}
fflush(stdin);
printf("\n\n");
system("pause");
}
}
void searchrec(int j)
{
char name[50],namet[50];
int a=1,choice;
char c='y';
if (j==1)
{
while(c=='y'||c=='Y')
{
int a=1;
system("cls");
printf("\n\t******************************************************************");
printf("\n\t *************************** ");
printf("\n\t********************* SEARCH RECORD *******************");
printf("\n\t *************************** ");
printf("\n\t******************************************************************");
printf("\n\n\t\tPLEASE CHOOSE SEARCH TYPE::");
printf("\n\n\t\t1::Search by name::");
printf("\n\n\t\t2::Search by class::");
printf("\n\n\t\t3::Search by rollno::");
printf("\n\n\t\t4::Exit");
printf("\n\n\t\t::Enter your choice:: ");
fflush(stdin);
scanf("%d",&choice);
if (choice==1)
{
a=1;
printf("\n\nEnter name of student to search: ");
fflush(stdin);
scanf("%[^\n]",name);
fs=fopen("student","rb");
while(fread(&stud,sizeof(stud),1,fs)==1)
{
if (strcmpi(name,stud.n)==0)
{
a=0;
printf("\nname = %s",stud.n);
printf("\nclass = %d",stud.c);
printf("\nroll no = %d",stud.r);
printf("\nmonthy fee =%.2f",stud.f);
printf("\nlast fee paid in month =%2d",stud.dt.m);
printf("\n due=%.2f",stud.due);
printf("\n fine=%.2f",stud.fine);
printf("\n total=%.2f\n\n",stud.tot);
}
}
if (a==1)
printf("\n\nRECORD NOT FOUND");
printf("\n\n");
system("pause");
fflush(stdin);
fclose(fs);
}
else if (choice==2)
{
int cl;
a=1;
printf("\n\nEnter class of student to search: ");
fflush(stdin);
cl=clscanf();
fs=fopen("student","rb");
while(fread(&stud,sizeof(stud),1,fs)==1)
{
if (stud.c==cl)
{
a=0;
printf("\nname = %s",stud.n);
printf("\nclass = %d",stud.c);
printf("\nroll no = %d",stud.r);
printf("\nmonthy fee =%.2f",stud.f);
printf("\nlast fee paid in month =%2d",stud.dt.m);
printf("\n due=%.2f",stud.due);
printf("\n fine=%.2f",stud.fine);
printf("\n total=%.2f",stud.tot);
}
}
if (a==1)
printf("\n\nRECORD NOT FOUND");
printf("\n\n");
system("pause");
fflush(stdin);
fclose(fs);
}
else if (choice==3)
{
int rll;
a=1;
printf("\n\nEnter roll of student to search: ");
fflush(stdin);
rll=clscanf();
fs=fopen("student","rb");
while(fread(&stud,sizeof(stud),1,fs)==1)
{
if (strcmpi(name,stud.n)==0)
{
a=0;
printf("\nname = %s",stud.n);
printf("\nclass = %d",stud.c);
printf("\nroll no = %d",stud.r);
printf("\nmonthy fee =%.2f",stud.f);
printf("\nlast fee paid in month =%2d",stud.dt.m);
printf("\n due=%.2f",stud.due);
printf("\n fine=%.2f",stud.fine);
printf("\n total=%.2f",stud.tot);
}
}
if (a==1)
printf("\n\nRECORD NOT FOUND");
printf("\n\n");
system("pause");
fflush(stdin);
fclose(fs);
}
else if(choice==4)
{
ext();
}
else
{
printf("\n\n\n\t\tINVALID ENTRY!!!!\n\n\t\t");
system("pause");
searchrec(1);
}
printf("\n\nDo you want to continue with the process(press y or Y");
fflush(stdin);
c=getch();
}
getch();
}
if (j==2)
{
while(c=='y'||c=='Y')
{
int a=1;
printf("\n\nname of teacher/staff to search: ");
fflush(stdin);
scanf("%[^\n]",namet);
ft=fopen("teacher","rb");
while(fread(&tech,sizeof(tech),1,ft)==1)
{
if (strcmp(namet,tech.n)==0)
{
a=0;
printf("\nname = %s",tech.n);
printf("\nteacher/staff id = %d",tech.id);
printf("\nmonth till when salary is paid =%d",tech.dt.m);
printf("\nmonthy salary = %.2f",tech.sal);
printf("\nadvance paid = %.2f",tech.adv);
}
}
if (a==1)
printf("\n\nRECORD NOT FOUND");
printf("\n\n");
system("pause");
fflush(stdin);
fclose(ft);
printf("\n\nDo you want to continue with the process(press y or Y");
fflush(stdin);
c=getch();
}
getch();
}
}
void modrec(int j)
{
char name[50];
int a=1,choice,cl,rolno;
char c='y';
if (j==1)
{
while(c=='y'||c=='Y')
{
system("cls");
printf("\n\t******************************************************************");
printf("\n\t *************************** ");
printf("\n\t********************* MODIFY RECORD *******************");
printf("\n\t *************************** ");
printf("\n\t******************************************************************");
printf("\n\n\t\tPLEASE CHOOSE MODIFY TYPE::");
printf("\n\n\t\t1::Modify by name::");
printf("\n\n\t\t2::Modify by name &class::");
printf("\n\n\t\t3::Modify by name,class & rollno::");
printf("\n\n\t\t4::Exit");
printf("\n\n\t\t::Enter your choice:: ");
fflush(stdin);
scanf("%d",&choice);
if (choice==1)
{
int a=0;
printf("\n\nenter name of student to modify: ");
fflush(stdin);
scanf("%[^\n]",name);
fs=fopen("student","rb+");
while(fread(&stud,sizeof(stud),1,fs)==1)
{
a=1;
if (strcmpi(name,stud.n)==0)
{
a=0;
printf("\nenter new name of student: ");
fflush(stdin);
scanf("%[^\n]",stud.n);
printf("\nenter new class of student: ");
fflush(stdin);
stud.c=clscanf();
printf("\nenter new roll of student: ");
fflush(stdin);
scanf("%d",&stud.r);
fseek(fs,-sizeof(stud),SEEK_CUR);
fwrite(&stud,sizeof(stud),1,fs);
fclose(fs);
}
}
if (a==1)
printf("\n\nRECORDS NOT FOUND");
else
printf("\n\nRECORDS SUCCESSFULLY MODIFIED");
printf("\n\n");
system("pause");
}
else if (choice==2)
{
int a=0;
printf("\n\nenter name of student to modify: ");
fflush(stdin);
scanf("%[^\n]",name);
printf("\n\nenter class of student to modify: ");
fflush(stdin);
cl=clscanf();
fs=fopen("student","rb+");
while(fread(&stud,sizeof(stud),1,fs)==1)
{
a=1;
if (strcmpi(name,stud.n)==0 && cl==stud.c)
{
a=0;
printf("\nenter new name of student: ");
fflush(stdin);
scanf("%[^\n]",stud.n);
printf("\nenter new class of student: ");
fflush(stdin);
stud.c=clscanf();
printf("\nenter new roll of student: ");
fflush(stdin);
scanf("%d",&stud.r);
fseek(fs,-sizeof(stud),SEEK_CUR);
fwrite(&stud,sizeof(stud),1,fs);
fclose(fs);
}
}
if (a==1)
printf("\n\nRECORDS NOT FOUND");
else
printf("\n\nRECORDS SUCCESSFULLY MODIFIED");
printf("\n\n");
system("pause");
}
else if (choice==3)
{
int a=0;
printf("\n\nenter name of student to modify: ");
fflush(stdin);
scanf("%[^\n]",name);
printf("\n\nenter class of student to modify: ");
fflush(stdin);
cl=clscanf();
printf("\n\nenter roll of student to modify: ");
fflush(stdin);
scanf("%d",&rolno);
fs=fopen("student","rb+");
while(fread(&stud,sizeof(stud),1,fs)==1)
{
a=1;
if (strcmpi(name,stud.n)==0 && cl==stud.c &&rolno==stud.r)
{
a=0;
printf("\nenter new name of student: ");
fflush(stdin);
scanf("%[^\n]",stud.n);
printf("\nenter new class of student: ");
fflush(stdin);
stud.c=clscanf();
printf("\nenter new roll of student: ");
fflush(stdin);
scanf("%d",&stud.r);
fseek(fs,-sizeof(stud),SEEK_CUR);
fwrite(&stud,sizeof(stud),1,fs);
fclose(fs);
}
}
if (a==1)
printf("\n\nRECORDS NOT FOUND");
else
printf("\n\nRECORDS SUCCESSFULLY MODIFIED");
printf("\n\n");
system("pause");
}
else if (choice==4) ext();
else
{
printf("\n\n\n\t\tINVALID ENTRY!!!!\n\n\t\t");
system("pause");
modrec(1);
}
printf("\n\nDo you want to continue with the process(press y or Y");
fflush(stdin);
c=getch();
}
getch();
}
if (j==2)
{
while(c=='y'||c=='Y')
{
int a=1;
printf("enter name of teacher to modify: ");
fflush(stdin);
scanf("%[^\n]",name);
ft=fopen("teacher","rb+");
while(fread(&tech,sizeof(tech),1,ft)==1)
{
if (strcmpi(name,tech.n)==0)
{
a=0;
printf("\nenter new name of teacher: ");
fflush(stdin);
scanf("%[^\n]",tech.n);
printf("\nenter new id of teacher: ");
fflush(stdin);
scanf("%d",&tech.id);
fseek(ft,-sizeof(tech),SEEK_CUR);
fwrite(&tech,sizeof(tech),1,ft);
fclose(ft);
}
}
if (a==1)
printf("\n\nRECORD NOT FOUND");
else
printf("\n\nRECORD SUCCESSFULLY MODIFIED");
printf("\n\n");
system("pause");
fflush(stdin);
printf("\n\nDo you want to continue with the process(press y or Y");
fflush(stdin);
c=getch();
}
getch();
}
}
void delrec(int j)
{
system("cls");
printf("\n\t******************************************************************");
printf("\n\t *************************** ");
printf("\n\t********************* DELETE RECORD *******************");
printf("\n\t *************************** ");
printf("\n\t******************************************************************");
FILE *temp,*t1;
int a=1;
char name[50],c='y';
if (j==1)
{
while(c=='y'||c=='Y')
{
int a=1;
printf("\n\nenter name of student to delete: ");
fflush(stdin);
scanf("%[^\n]",name);
fs=fopen("student","rb");
temp=fopen("tempfile","wb");//opening of temporary file for deleting process
while (fread(&stud,sizeof(stud),1,fs)==1)
{
if (strcmp(stud.n,name)==0)
{
a=0;
continue;
}
else
{
fwrite(&stud,sizeof(stud),1,temp);
}
}
if (a==1)
printf("\n\nRECORD NOT FOUND");
else
printf("\n\nRECORD SUCCESSFULLY DELETED");
printf("\n\n");
system("pause");
fflush(stdin);
fclose(fs);
fclose(temp);
system("del student");/*all data except the data to be
deleted in student were 1st moved to temp and data in student
was deleted*/
system("ren tempfile, student");//renaming temp to student
printf("\n\nDo you want to continue with the process(press y or Y");
fflush(stdin);
c=getch();
}
getch();
}
if (j==2)
{
a=1;
char namet[50];
while(c=='y'||c=='Y')
{
printf("\n\nEnter name of teacher to delete record: ");
fflush(stdin);
scanf("%[^\n]",namet);
ft=fopen("teacher","rb");
t1=fopen("tempfile1","wb");
while (fread(&tech,sizeof(tech),1,ft)==1)
{
if (strcmp(tech.n,namet)==0)
{
a=0;
continue;
}
else
{
fwrite(&tech,sizeof(tech),1,t1);
}
}
if (a==1)
printf("\n\nRECORD NOT FOUND");
else
printf("\n\nRECORD SUCCESSFULLY DELETED");
printf("\n\n");
system("pause");
fflush(stdin);
fclose(ft);
fclose(t1);
system("del teacher");
system("ren tempfile1, teacher");
printf("\n\nDo you want to continue with the process(press y or Y");
fflush(stdin);
c=getch();
}
getch();
}
}
void salary(int mm)
{
system("cls");
printf("\n\t******************************************************************");
printf("\n\t *************************** ");
printf("\n\t********************* SALARY *******************");
printf("\n\t *************************** ");
printf("\n\t******************************************************************");
FILE *f,*t;
int a=1,day;
char name[50],c='y';
int month,dif,id;
while(c=='y'||c=='Y')
{
int a=1;
fflush(stdin);
printf("\n\nEnter name:: ");
scanf("%[^\n]",name);
printf("\n\nEnter ID:: ");
scanf("%d",&id);
f=fopen("teacher","rb+");
t=fopen("te","wb+");
while(fread(&tech,sizeof(tech),1,f)==1)//file opened
{
if(strcmp(tech.n,name)==0 )//name entered is compared to the existing name in file
{
float lsal;
a=0;
printf("\n\nEnter the month till which salary is to be paid:: ");
fflush(stdin);
scanf("%d",&month);
month=chkdat(month,day);
tech.adv=(month-mm-1)*tech.sal;
if (tech.adv<0) tech.adv=0;
lsal=mm-tech.dt.m;//months of salary left to be paid
if(lsal<0) lsal=0;
tech.tot=tech.adv+tech.sal*(1+lsal);
if(month==tech.dt.m) tech.tot=0;
printf("\nmonthy salary left to be paid:: %.2f",lsal);
printf("\ntotal :: %.2f",tech.tot);
printf("\nadvance :: %.2f",tech.adv);
tech.dt.m=month;
fwrite(&tech,sizeof(tech),1,t);
fclose(f);
fclose(t);
if (a==1)
printf("\n\nRECORD NOT FOUND");
printf("\n\n");
system("pause");
fflush(stdin);
system("del teacher");
system("ren te, teacher");
}
}
printf("\n\nDo you want to continue with the process(press y or Y");
fflush(stdin);
c=getch();
}
getch();
}
void fee(int mm)
{
system("cls");
printf("\n\t******************************************************************");
printf("\n\t *************************** ");
printf("\n\t********************* FEE *******************");
printf("\n\t *************************** ");
printf("\n\t******************************************************************");
FILE *f,*t;
int a=0;
char name[50],c='y';
int clas, roll,month,dif;
while(c=='y'||c=='Y')
{
int a=1,day=0;
fflush(stdin);
printf("\n\nEnter name:: ");
scanf("%[^\n]",name);
printf("\n\nEnter class:: ");
fflush(stdin);
clas=clscanf();
printf("\n\nEnter roll:: ");
fflush(stdin);
scanf("%d",&roll);
f=fopen("student","rb+");
t=fopen("te","wb");
while(fread(&stud,sizeof(stud),1,f)==1)
{
if(strcmp(stud.n,name)==0 && clas==stud.c && roll==stud.r)
{
a=0;
printf("\n\nEnter the month till which fee to be paid:: ");
fflush(stdin);
scanf("%d",&month);
month=chkdat(month,day);
dif=mm-stud.dt.m;
stud.fine=(dif*stud.f)*0.01;
stud.due=(dif)*stud.f;
if (stud.fine<0) stud.fine=0;
if (stud.due<0) stud.due=0;
if (stud.tot<0) stud.tot=0;
stud.tot=stud.fine+stud.due+stud.adv;
printf("\nfine :: %.2f",stud.fine);
printf("\ndue :: %.2f",stud.due);
printf("\ntotal :: %.2f",stud.tot);
printf("\nadvance :: %.2f",stud.adv);
stud.dt.m=month;
stud.tot=0;
stud.fine=0;
stud.due=0;
fwrite(&stud,sizeof(stud),1,t);
}
}
if (a==1)
printf("\n\nRECORD NOT FOUND");
printf("\n\n");
system("pause");
fflush(stdin);
fclose(f);
fclose(t);
system("del student");
system("ren te, student");
printf("\n\nDo you want to continue with the process(press y or Y");
fflush(stdin);
c=getch();
}
getch();
}
void ext()
{
int i;
system("color 0c");
printf("\n\n\t\t Thank you for using C Program School Billing System Project\n\n");
system("pause");
system("cls");
printf("\n\n\t\t\t Exiting\n\n");
for(i=1; i<=80; i++)
{
Sleep(50);
printf("*");
}
exit(0);
}
int chkdat(int mnt,int dnt)
{
int mon,day;
if (mnt>12 || mnt<1 || dnt<1 || dnt>32)
{
MessageBox(0,"Invalid Date!\nEnter Again","Error!",0);
fflush(stdin);
scanf("%d%d",&mon,&day);
mon=chkdat(mon,day);
}
else
return (mnt);
}
int clscanf()
{
int mnt,mon;
fflush(stdin);
scanf("%d",&mnt);
if (mnt>12 ||mnt<1)
{
MessageBox(0,"Invalid Class!\nEnter Class","Error!!",0);
fflush(stdin);
mon=clscanf();
}
else
return mnt;
}
/*
👋 Hi, I’m @aarushinair - Aarushi Nair (she/her/ella)
👀 I’m a Computer Science Engineering Student
💞️ I’m looking to collaborate on #java, #python, #R, #applicationdevelopment
🌱 #GirlsWhoCode #WomenInTech #WomenInIT #WomenInSTEM #CyberSecurity #QuantumComputing #BlockChain #AI #ML
📫 How to reach me: https://www.linkedin.com/in/aarushinair/
👩🏫 YouTube Channel - Code with Aarushi : https://www.youtube.com/channel/UCKj5T1ELHCmkGKujkpqtl7Q
🙋 Follow me on Twitter: https://twitter.com/aarushinair_
*/