library fine - c program
language: this is a C program
software used : code blocks
short name : library fine
topic:
A library charges fine for every book returned late. For the first 5 days the fine is 50 paise(0.50 rupee) per day,for 6-10 days fine is one rupee per day and above 10 days fine is 5 rupees per day. If you returned the book after 30 days your membership will be canceled. Write a program to accept the number of days the member is late to return the book and display the fine or the appropriate message.
solution :
#include<stdio.h>
void main()
{
int days;
float fine;
printf("enter the number of late days : ");
scanf("%d",&days);
if(days<=30)
{
if(days<=30&&days>10)
fine=7.5+((days-10)*5);
else if(days<=10&&days>5)
fine=2.5+((days-5)*1);
else if(days<6&&days>0)
fine=days*0.5;
printf("fine= %.2f\n\n",fine);
}
else printf("your membership is canceled\n\n");
}
the output :

N:B - you can also use #include<conio.h>, clrscr( ); and getch( ); if you use 'turbo c' or some old software.As i used codeblocks it was not needed.
software used : code blocks
short name : library fine
topic:
A library charges fine for every book returned late. For the first 5 days the fine is 50 paise(0.50 rupee) per day,for 6-10 days fine is one rupee per day and above 10 days fine is 5 rupees per day. If you returned the book after 30 days your membership will be canceled. Write a program to accept the number of days the member is late to return the book and display the fine or the appropriate message.
solution :
#include<stdio.h>
void main()
{
int days;
float fine;
printf("enter the number of late days : ");
scanf("%d",&days);
if(days<=30)
{
if(days<=30&&days>10)
fine=7.5+((days-10)*5);
else if(days<=10&&days>5)
fine=2.5+((days-5)*1);
else if(days<6&&days>0)
fine=days*0.5;
printf("fine= %.2f\n\n",fine);
}
else printf("your membership is canceled\n\n");
}
the output :
N:B - you can also use #include<conio.h>, clrscr( ); and getch( ); if you use 'turbo c' or some old software.As i used codeblocks it was not needed.
This comment has been removed by the author.
ReplyDelete