HOTEL TARRIF CALCULATOR
Problem Description
Write a C program to calculate the hotel tariff. The room rent is 20% high during peak seasons [April and May] . Use Switch statement.
Input Format:
The first line of the input contains an integer which corresponds to the number of the month. [ January is 1, Feb is 2 and so on]. The second line of the input consists of a floating point number which corresponds to the room rent per day. The third line of the input consists of an integer which corresponds to the number of days stayed in the hotel.
Output Format:
Output consists of a single line which displays the hotel tariff to be payed. Hotel tariff should be displayed correct to 2 decimal places. Refer sample output for format details.
CODING ARENA
#include <stdio.h>
int main()
{
int a,c;
float b,d;
scanf("%d%f%d",&a,&b,&c);
if(a==4 || a==5)
{
d=(b/5)*c;
printf("Rs.%.2f",d+(c*b));
}
else
printf("Rs.%.2f",b*c);
return 0;
}
Test Case 1
Input (stdin)3
1500
2
Expected Output
Rs.3000.00
Test Case 2
Input (stdin)11
3000
4
Expected Output
Rs.12000.00
No comments:
Post a Comment