You are given an electricity project for the calculation of amount for the consumed electricity units for every one month.
1) For the electricity units (0-200) is 50 paisa per units.
2) For the electricity units (201-400) is 65 paisa per unit. For the first 0-200 consumed units charge is 100 rupees, if the consumer consumed greater than 200 and less than or equal to 400 unit, then for each unit charge is 65 paisa.
3)For the electricity units (401-600) is 80 paisa per unit. For the first 0-400 consumed units charge is 230 rupees, if the consumer consumed greater than 400 unit and less than or equal to 600, then for each unit charge is 80 paisa.
4)For the electricity units above 600, the price for each unit is 80 paisa. For the first 0-600 units charge is 390 rupees, if the consumer consumed greater than 600 unit, then for each unit charge 1.50 paisa.
Case= Test 1
input=
123
100
output=
Electricity Amount to be paid is:50.00
Case= Test 2
input=
124
300
output=
Electricity Amount to be paid is:165.00
#include <stdio.h>
int main()
{
int month;
float el_units, sum;
sum = 0;
printf("Enter month: ");
scanf("%d", &month);
printf("Enter consumed electricity units: ");
scanf("%f", &el_units);
if (el_units <= 200)
sum = (el_units * 0.50);
else if ((el_units >= 201) & (el_units <= 400))
sum = (100 + (el_units - 200) * 0.65);
else if ((el_units >= 401) & (el_units <= 600))
sum =(230 + (el_units - 400) * 80);
else if ((el_units >= 401) & (el_units <= 600))
sum =(390 + (el_units - 600) * 1.5);
printf("\n\nElectricity Amount to be paid is: %.2f\n", sum);
}
Comments
Leave a comment