HOTEL TARIFF CALCULATOR

Description:

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: 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. 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 :

#include<stdio.h>
void p(float);
int main()
{
  int month,n;
  float rent,t=0,r=0;
  scanf("%d\n",&month);
  scanf("%f\n",&rent);
  scanf("%d\n",&n);
  t=rent*n;
  r=((rent+(rent*0.2))*n);
  
  switch(month)
  {
    case 1:
      p(t);
      break;
    case 2:
      p(t);
      break;
    case 3:
      p(t);
      break;
    case 4:
      p(r);
      break;
    case 5:
      p(r);
      break;
    case 6:
      p(r);
      break;
    case 7:
      p(t);
      break;
    case 8:
      p(t);
      break;
    case 9:
      p(t);
      break;
    case 10:
      p(t);
      break;
    case 11:
      p(r);
      break;
    case 12:
      p(r);
      break;
    
     
    default: printf("Invalid Input");
    break;
  }
  return 0;
}
  void p(float t)
  {
    printf("Hotel Tariff: Rs.%.2f",t);
  }