-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbillmanager.c
More file actions
126 lines (105 loc) · 2.54 KB
/
billmanager.c
File metadata and controls
126 lines (105 loc) · 2.54 KB
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
#include <stdio.h>
#include<string.h>
#include<stdlib.h>
struct bills
{
int bill_no;
char bill_name[200];
struct date
{
int day;
int month;
int year;
} dd_mm_yy;
};
typedef struct bills BILLS;
BILLS b[1000];
void
bill_add (int n)
{
int i = 0;
for (i = 0; i < n; i++)
{
printf ("Enter bill no \n");
scanf ("%d", &b[i].bill_no);
printf ("Enter bill_name \n");
scanf ("%s", b[i].bill_name);
printf ("Enter due-date in dd_mm_yy format \n");
printf ("Day : ");
scanf ("%d", &b[i].dd_mm_yy.day);
printf ("Month : ");
scanf ("%d", &b[i].dd_mm_yy.month);
printf ("Year : ");
scanf ("%d", &b[i].dd_mm_yy.year);
}
}
void
due_check (int n)
{
char bname[1000];
int i = 0, tday = 0, tmonth = 0, tyear = 0, dmonth = 0, tleft = 0;
printf ("enter the name of bill to check due date \n");
scanf ("%s", bname);
printf ("Enter today's date (day,month and year) \n");
scanf ("%d%d%d", &tday, &tmonth, &tyear);
for (i = 0; i < 100; i++)
{
if ((strcmp (bname, b[i].bill_name)) == 0)
{
if ((b[i].dd_mm_yy.year < tyear) || (b[i].dd_mm_yy.month < tmonth)
|| (b[i].dd_mm_yy.day < tday))
{
printf ("Time Expired!!! \n Due Date was:\n");
printf ("%d:%d:%d \n", b[i].dd_mm_yy.day, b[i].dd_mm_yy.month,
b[i].dd_mm_yy.year);
}
else
{
if (tyear < b[i].dd_mm_yy.year)
{
printf ("Don't worry.Enough time for payment \n");
printf ("Due Date is:%d:%d:%d \n", b[i].dd_mm_yy.day,
b[i].dd_mm_yy.month, b[i].dd_mm_yy.year);
}
else if (tmonth < b[i].dd_mm_yy.month)
{
dmonth = b[i].dd_mm_yy.month - tmonth;
tleft = (dmonth * 30) + b[i].dd_mm_yy.day - tday;
printf ("Due Date :%d:%d:%d \n", b[i].dd_mm_yy.day,
b[i].dd_mm_yy.month, b[i].dd_mm_yy.year);
printf ("Time left for payment is %d days: \n", tleft);
}
}
return;
}
}/*closing of for*/
printf ("no such bill \n");
}
int
main ()
{
int ch = 0, n = 0;
printf("....Make your choice....\n 1.Check due date of bills \n 2.Add new bills\n 3.Exit \n");
scanf ("%d", &ch);
do
{
switch (ch)
{
case 1:
due_check (100);
break;
case 2:
printf ("How many bills to add? \n");
scanf ("%d", &n);
bill_add (n);
break;
default:
printf ("Thank You for coming \n");
}
printf
("....Make your choice....\n 1.Check due date of bills \n 2.Add new bills \n 3.Exit \n");
scanf ("%d", &ch);
}
while (ch != 3);
return 0;
}