College Library FinesIn a college library fines are issued according to the subsequent condition. If return books exceeds the due date. Up to five days 20 rs fine. 6-10 days 50 rs fine. >10 days 100 rs fine. More than 30 days membership will be cancelled. Get the due date from the user and compute.
Answers
Answered by
2
#include <stdio.h>
#include <windows.h> // or time.h for unix
// we will not consider leap year, daylight savings for this simple program
// first entry for dec. last entry is also dec.
int yearDays[13] = {31, 62,90, 121, 151, 182, 212, 243, 274, 304, 335, 365, 396 };
int monthDays[13] = {31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31 };
main ()
{
int fine, curDate, curMonth, dueDate, dueMonth, m, n;
char *msg;
getCurMonth(&curDate, &curMonth);
getDueDateMonth(&dueDate, &dueMonth);
if (dueMonth==12 && curMonth == 1)
m = dueDate;
else
m = dueDate + yearDays[dueMonth-1];
n = curDate + yearDays[curMonth-1] ;
fine = CalculateFine (m, n);
switch (fine) {
case -1: cancelMemberShip();
msg = "Due date More than 30 days. Membership Cancelled\n";
break;
case 0: msg = "Good Day Member \n"; break;
default: sprintf(msg,"%s : %d, "Pay Fine ", fine); break;
}
printf("%s \n", msg);
}
int CalculateFine (int m, int n)
{
int fine;
if (m >= n) ; fine = 0;
else if (n - m <= 5) fine = 20;
else if (n - m <= 10) fine = 50;
else if (n - m <= 30) fine = 100;
else fine = -1;
}
getDueDateMonth(int *date, int *month)
{
printf("enter due month: "); scanf("%d", date);
printf("enter due date : "); scanf("%d", month);
}
getCurDateMonth(int *date, int *month)
{
// for windows
SYSTEM_TIME str_time ;
GetSystemTime( &str_time);
*date = str_time.wDay ;
*month = str_time.wMonth;
// for unix
// use asctime() ; or ctime();
// get the data and month
// or use system("date >> file");
}
#include <windows.h> // or time.h for unix
// we will not consider leap year, daylight savings for this simple program
// first entry for dec. last entry is also dec.
int yearDays[13] = {31, 62,90, 121, 151, 182, 212, 243, 274, 304, 335, 365, 396 };
int monthDays[13] = {31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31 };
main ()
{
int fine, curDate, curMonth, dueDate, dueMonth, m, n;
char *msg;
getCurMonth(&curDate, &curMonth);
getDueDateMonth(&dueDate, &dueMonth);
if (dueMonth==12 && curMonth == 1)
m = dueDate;
else
m = dueDate + yearDays[dueMonth-1];
n = curDate + yearDays[curMonth-1] ;
fine = CalculateFine (m, n);
switch (fine) {
case -1: cancelMemberShip();
msg = "Due date More than 30 days. Membership Cancelled\n";
break;
case 0: msg = "Good Day Member \n"; break;
default: sprintf(msg,"%s : %d, "Pay Fine ", fine); break;
}
printf("%s \n", msg);
}
int CalculateFine (int m, int n)
{
int fine;
if (m >= n) ; fine = 0;
else if (n - m <= 5) fine = 20;
else if (n - m <= 10) fine = 50;
else if (n - m <= 30) fine = 100;
else fine = -1;
}
getDueDateMonth(int *date, int *month)
{
printf("enter due month: "); scanf("%d", date);
printf("enter due date : "); scanf("%d", month);
}
getCurDateMonth(int *date, int *month)
{
// for windows
SYSTEM_TIME str_time ;
GetSystemTime( &str_time);
*date = str_time.wDay ;
*month = str_time.wMonth;
// for unix
// use asctime() ; or ctime();
// get the data and month
// or use system("date >> file");
}
kvnmurty:
clik on thanks. select best ans..
Similar questions