| Current Path : /var/www/html/bibhas.ghoshal/ITP_2019/lab/ |
| Current File : /var/www/html/bibhas.ghoshal/ITP_2019/lab/prog11.c |
#include <stdio.h>
int main(void)
{
short hours_left, rate;
float ticket_price, refund_amount;
printf("Enter price of ticket: ");
scanf("%f", &ticket_price);
printf("Number of hours before train departure: ");
scanf("%hd", &hours_left);
if (ticket_price <= 0) {
printf("Price can't be negative\n");
return 1;
}
else if (ticket_price > 10000) {
printf("Price can't exceed Rs 10,000.\n");
return 1;
}
else if (hours_left > 48)
rate = 0;
else if (hours_left > 6)
rate = 25;
else if (hours_left > -2) /* 2 hours after departure */
rate = 50;
else
rate = 100; /* No refund */
refund_amount = ticket_price *(100 - rate) / 100;
printf("Refund amount %.2f\n", refund_amount);
return 0;
}