Write a C program to calculate the hotel tariff. The room rent is 20% high during peak seasons [April-June, November-December]. 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:
The output consists of a single line which displays the hotel tariff to be payed. Hotel tariff should be displayed correctly to 2 decimal places. Refer sample output for format details.
Sample Input 1:
3
1500
2
Sample Output 1:
Hotel Tariff: Rs.3000.00
Sample Input 2:
4
2000
2
Sample Output 2:
Hotel Tariff: Rs.4800.00
Sample Input 3:
14
Sample Output 3:
Invalid Input
Program Code:
#include<stdio.h>
int main()
{
int m, d;
float r, total;
scanf("%d", &m);
scanf("%f", &r);
scanf("%d", &d);
switch(m)
{
case 1:
case 2:
case 3:
total = r*d;
printf("Hotel Tariff: Rs.%.2f", total);
break;
case 4:
case 5:
case 6:
total = r*d;
total+=0.2*total;
printf("Hotel Tariff: Rs.%.2f", total);
break;
case 7:
case 8:
case 9:
case 10:
total = r*d;
printf("Hotel Tariff: Rs.%.2f", total);
break;
case 11:
case 12:
total = r*d;
total+=0.2*total;
printf("Hotel Tariff: Rs.%.2f", total);
break;
default:
printf(" Invalid Input");
}
return 0;
}
Post A Comment:
0 comments: