Thursday 25 July 2013

Chapter 2 solutions Problem [F][e]

Question-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.
Solution-
it's a good question.Here is the solution.

#include<stdio.h>
int main()
{
int days;
float fine;
printf("Enter how many days late you are\n");
scanf("%d",&days);
if(days<=5)
fine=days*0.5;
printf("Fine=%d\n",fine);
if(days>5&&days<=10)
fine=days*0.5;
fine=fine+(days-5)*1;
printf("Fine=%d\n",fine);
if(days>10&&days<=30)
fine=days*0.5;
fine=fine+5+(days-10)*5;
printf("Fine=%d\n",fine);
if(days>30)
printf("Your membership has been canceled\n");
return 0;
}

1 comment:

  1. But in question it is not written per day so why we should calculate per day
    Please help me
    Tomorrow is my exam please

    ReplyDelete