A library charges a fine for every book returned late. For first 5 days the fine is 50 Rs, for 6-10 days fine is 100 rupee and above 10 days fine is 150 rupees. If you return the book after 30 days your membership will be cancelled. Write a program C# to accept the number of days the member is late to return the book and display the fine or the appropriate message.
#include <iostream>
using namespace std;
int main()
{
cout << "Enter number of days: ";
int days;
cin >> days;
cout << endl;
double fine;
string membership = "";
if(days <= 5)
fine = 50;
else if(days > 5 && days <= 10)
fine = 100;
else
{
fine = 150;
if(days > 30)
membership = "Your membership was cancelled.";
}
cout << "Fine: " << fine << " rupees" << endl;
cout << membership << endl;
cout << endl << endl;
return 0;
}
Comments
Leave a comment