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()
{
int uni;
float cost;
scanf("%d",&uni);
if(uni>0&&uni<=200)
cost=uni*0.5;
else if(uni>200&&uni<=400)
cost=(uni-200)*0.65+100;
else if(uni>400&&uni<=600)
cost=(uni-400)*0.80+230;
else cost=390;
printf("Rs=%0.2f",cost);
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