Program: 84
A library charges a fine for every book returned late. For first 5 days the fine is 50 paise per day, for 6-10 days fine is one rupee per day and above 10 days fine is 5 rupees per day. If you return the book after 30 days your membership will be cancelled. Write a c program to accept the number of days the member is late to return the book and display the fine appropriate message.
#include<stdio.h> #include<conio.h> int main() { int days; float fine; printf("Enter the number of days: "); scanf("%d", &days); if (days > 0 && days <= 5) fine = 0.50 * days; if (days >= 6 && days <= 10) fine = 1 * days; if (days > 10) fine = 5 * days; if (days > 30) { printf("Your membership would be canceled.\n"); } printf("You have to pay Rs. %.2f fine.", fine); }
Output:
Enter the number of days: 5 You have to pay Rs. 2.50 fine. Enter the number of days: 10 You have to pay Rs. 10.00 fine. Enter the number of days: 13 You have to pay Rs. 65.00 fine. Enter the number of days: 31 Your membership would be canceled. You have to pay Rs. 155.00 fine.
Leave a Comment