Monday, August 20, 2018

ELECTRICITY CHARGE CALCULATION

  • Problem Description

    Tom want to know about the calculation of electricity charges. Explain him about the calculation by using C code to reads the customer number and power consumed and prints the amount to be paid by the customer.Consumption Rate of
    Units Charge
    ------------------------------------------------------
    0-200 Rs.0.50 per unit
    201-400 Rs.100 plus Rs.0.65 per unit excess 200
    401-600 Rs.230 plus Rs.0.80 per unit excess of 400.
    ------------------------------------------------------
  • CODING ARENA
  • #include <stdio.h>
    int main()
    {
      float  a; 
      scanf("%f",&a); 
      if(a<=200)
        {
        a=a*0.50;
      printf("Rs=%.2f",a); 
        }
      else if(a>200 && a<=400)
        {
        a=100+(a-200)*0.65;
        printf("Rs=%.2f",a);
        }
      else if (a>400 && a<=600)
        {
        a=100+130+(a-400)*0.80;
        printf("Rs=%.2f",a);
        }

    return 0;
    }
  • Test Case 1

    Input (stdin)
    100
    
    
    Expected Output
    Rs=50.00
  • Test Case 2

    Input (stdin)
    300
    
    
    Expected Output
    Rs=165.00

No comments:

Post a Comment