The program is written in C++ programming language and calculates the fine amount for late membership renewal based on the number of days a member has delayed the renewal.
The program starts by declaring a variable named "days" of integer data type. The user is then prompted to enter the number of days the membership has been delayed. The input value is stored in the variable "days" using the "cin" function.
The program then uses an if-else statement to check the value of the variable "days" and calculates the fine amount accordingly. If the value of "days" is between 1 and 5, the fine amount is 0.50 per day. If the value of "days" is between 6 and 10, the fine amount is 1 per day. If the value of "days" is between 11 and 30, the fine amount is 5 per day.
If the value of "days" is greater than 30, the program displays a message stating that the membership will be cancelled. Finally, the program returns 0, indicating successful execution.
/* A library charges a fine for every book returned late. For first 5 days the fine is 50 paise, for 6-10 days fine is one rupee and above 10 days fine is 5 rupees. If you return the book after 30 days your membership will be cancelled. 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. >0 <=5 /0.50 >=6 <=10 /1 >10 <=30 /5 >30 */ #include<iostream> using namespace std; int main() { int days; cout<<"Enter the number of days:"; cin>>days; if(days>0 && days<=5) { cout<<"\nPer Day Fine Amount is : 0.50"; cout<<"\nTotal Fine Amount is : "<<days*0.50; } else if(days>=6 && days<=10) { cout<<"\nPer Day Fine Amount is : 1"; cout<<"\nTotal Fine Amount is : "<<days*1; } else if(days>10 && days<=30) { cout<<"\nPer Day Fine Amount is : 5"; cout<<"\nTotal Fine Amount is : "<<days*5; } else { cout<<"\nmembership will be cancelled."; } return 0; }
Enter the number of days:6 Per Day Fine Amount is : 1 Total Fine Amount is : 6To download raw file Click Here
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions