-
Notifications
You must be signed in to change notification settings - Fork 0
/
finepayment_function.cpp
98 lines (97 loc) · 1.94 KB
/
finepayment_function.cpp
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
void finepayment()
{
FILE *fp,*fp1;
int pr,fine;
char id[15],ch;
color();
setcolor(BLUE);
settextstyle(7,0,5);
outtextxy(100,30,"FINE PAYMENT PAGE");
gotoxy(30,10);
printf("ENTER STUDENT ID : ");
scanf("%s",&id);
fp=fopen("fine.txt","rb");
fread(&f,sizeof(f),1,fp);
while(!feof(fp))
{
if((strcmp(f.studentid,id))==0)
{
clrscr();
color();
setcolor(BLUE);
settextstyle(7,0,5);
outtextxy(100,30,"FINE PAYMENT PAGE");
gotoxy(30,10);
printf("STUDENT ID : %s",f.studentid);
gotoxy(30,12);
printf("FINE : %d",f.price);
fine=f.price;
fclose(fp);
goto out;
}
fread(&f,sizeof(f),1,fp);
}
fclose(fp);
color();
setcolor(BLUE);
settextstyle(7,0,5);
outtextxy(100,30,"FINE PAYMENT PAGE");
gotoxy(30,10);
printf("STUDENT ID : %s",id);
gotoxy(30,12);
printf("FINE : 0");
gotoxy(40,16);
getch();
studentid1();
out :
gotoxy(25,14);
printf("DO YOU WANT TO PAY FINE : ");
fflush(stdin);
scanf("%s",&ch);
if(ch=='y'||ch=='Y')
{
gotoxy(25,16);
printf(" PAYMENT IN RUPEES : ");
fflush(stdin);
scanf("%d",&pr);
fine=fine-pr;
gotoxy(10,10);
printf("%d",fine);
gotoxy(10,10);
printf("%d",fine);
gotoxy(10,10);
printf(" ");
fp1=fopen("fine1.txt","wb");
fp=fopen("fine.txt","rb");
fread(&f,sizeof(f),1,fp);
while(!feof(fp))
{
if((strcmp(f.studentid,id))!=0)
{
fwrite(&f,sizeof(f),1,fp1);
}
if((strcmp(f.studentid,id))==0)
{
f.price=fine;
fwrite(&f,sizeof(f),1,fp1);
}
fread(&f,sizeof(f),1,fp);
}
fclose(fp);
fclose(fp1);
remove("fine.txt");
rename("fine1.txt","fine.txt");
gotoxy(10,10);
printf(" ");
gotoxy(35,19);
printf("PAID");
gotoxy(38,21);
getch();
studentid1();
}
gotoxy(35,19);
printf("UNPAID");
gotoxy(38,21);
getch();
studentid1();
}