Ticker

6/recent/ticker-posts

Electricity Bill Program


Enter units to find electricity bill - 

Question- 

  • For first 50 units Rs. 2.50/unit
  • For next 100 units Rs. 2.75/unit
  • For next 100 units Rs. 4.20/unit
  • For unit above 250 Rs. 4.50/unit
  • An additional surcharge of 10% is added to the bill.


#include <stdio.h>
int main()
{
  float a,b,c ;
  scanf("%f",&a);
  if(a<=50)
  {
    b=(a*(2.50));
  }
  else if ((a>50)&&(a<=150))
  { 
     c=2.50*50;
     b=c+(a-50)*(2.75);
  }
 else if ((a>150)&&(a<=250))
  {
     c=2.50*50+2.75*100;
     b=c+(a-150)*(4.20); 
  }
 else
  {
     c=2.50*50+2.75*100+4.20*100;
     b=c+(a-250)*(4.50);
  }
  b=b+b*(0.1);
  printf ("%0.2f",b);
return 0;
}
Output -
500
2139.50

Post a Comment

0 Comments