-
Notifications
You must be signed in to change notification settings - Fork 0
/
5.c
102 lines (82 loc) · 3.64 KB
/
5.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
#include<stdio.h>
#include"structs.h"
//function for searching the issue records by issue date.
void search_by_issuedate(int ni, issuer issue_rec[])
{
int d,m,y;
scanf("%d %d %d%*c",&d,&m,&y); //taking the date as input d m y format.
int count =0;
for(int i = 0 ; i < ni ;i++)
{
if(i==0)
{
printf("\n\n%-25s %-15s %-8s %-30s %-22s %-20s %-5s \n\n","ISSUER NAME","ISSUER ID","BOOK ID","BOOK NAME","ISSUE DATE","RETURN DATE","FINE");
}
if( d == issue_rec[i].idate.d && m == issue_rec[i].idate.m && y == issue_rec[i].idate.y) //comparing the input and issue date of each record.
{
//if date is matched then printing the record.
printf("%-25s %-15s %-8d %-30s %5d-%d-%d %15d-%d-%-15d %d\n",issue_rec[i].iname, issue_rec[i].iid, issue_rec[i].bid,issue_rec[i].bname, issue_rec[i].idate.d,issue_rec[i].idate.m,issue_rec[i].idate.y,issue_rec[i].rdate.d,issue_rec[i].rdate.m,issue_rec[i].rdate.y,issue_rec[i].fine);
count++;
}
}
if(count==0)
{
printf("NO DATA FOUND\n"); //if none of the date in records match the input date.
}
}
//function for searching the issue records by return date.
void search_by_returndate(int ni, issuer issue_rec[])
{
int d,m,y;
scanf("%d %d %d%*c",&d,&m,&y); //taking the date as input d m y format.
int count =0;
for(int i = 0 ; i < ni ;i++ )
{
if(i==0)
{
printf("\n\n%-25s %-15s %-8s %-30s %-22s %-20s %-5s \n\n","ISSUER NAME","ISSUER ID","BOOK ID","BOOK NAME","ISSUE DATE","RETURN DATE","FINE");
}
if( d == issue_rec[i].rdate.d && m == issue_rec[i].rdate.m && y == issue_rec[i].rdate.y) //comparing the input and return date of each record.
{
//if date is matched then printing the record.
printf("%-25s %-15s %-8d %-30s %5d-%d-%d %15d-%d-%-15d %d\n",issue_rec[i].iname,issue_rec[i].iid,issue_rec[i].bid,issue_rec[i].bname, issue_rec[i].idate.d,issue_rec[i].idate.m,issue_rec[i].idate.y,issue_rec[i].rdate.d,issue_rec[i].rdate.m,issue_rec[i].rdate.y,issue_rec[i].fine);
count++;
}
}
if(count == 0)
{
printf("NO DATA FOUND\n"); //if none of the date in records match the input date.
}
}
//function for displaying the returned books.
void returned_books(issuer issue_rec[],int ni)
{
for(int i = 0 ; i < ni ; i++)
{
if(i==0)
{
printf("\n\n%-25s %-15s %-8s %-30s %-22s %-20s %-5s \n\n","ISSUER NAME","ISSUER ID","BOOK ID","BOOK NAME","ISSUE DATE","RETURN DATE","FINE");
}
if( issue_rec[i].rdate.d != 0 && issue_rec[i].rdate.m != 0 && issue_rec[i].rdate.y !=0) //checking if return date of each record is present.
{
//if present printing the record.
printf("%-25s %-15s %-8d %-30s %5d-%d-%d %15d-%d-%-15d %d\n",issue_rec[i].iname,issue_rec[i].iid,issue_rec[i].bid,issue_rec[i].bname, issue_rec[i].idate.d,issue_rec[i].idate.m,issue_rec[i].idate.y,issue_rec[i].rdate.d,issue_rec[i].rdate.m,issue_rec[i].rdate.y,issue_rec[i].fine);
}
}
}
//function for displaying the NOT returned books.
void not_returned_books(issuer issue_rec[],int ni)
{
for(int i = 0 ; i < ni ; i++)
{
if(i==0)
{
printf("\n\n%-25s %-15s %-8s %-30s %-22s %-20s %-5s \n\n","ISSUER NAME","ISSUER ID","BOOK ID","BOOK NAME","ISSUE DATE","RETURN DATE","FINE");
}
if( issue_rec[i].rdate.d == 0 && issue_rec[i].rdate.m == 0 && issue_rec[i].rdate.y ==0) //checking if return date of each record is present.
{
//if return date is not present then printing.
printf("%-25s %-15s %-8d %-30s %5d-%d-%d %15d-%d-%-15d %d\n",issue_rec[i].iname,issue_rec[i].iid,issue_rec[i].bid,issue_rec[i].bname, issue_rec[i].idate.d,issue_rec[i].idate.m,issue_rec[i].idate.y,issue_rec[i].rdate.d,issue_rec[i].rdate.m,issue_rec[i].rdate.y,issue_rec[i].fine);
}
}
}