An electricity board charges the following rates for the use of electricity: Number of Units Cost per Unit For the first 200 units Paise: 0.80per unit For the next 100 units Paise: 0.90per unit For t he next and above 300 units Rupee: 1.00per unit All users are charged a minimum of Rs. 100 as meter charge. If the total amount is more than Rs.400, then an additional surcharge of 15% of to tal amount is charged. Read the names of users and number of units consumed and print out t he charges with names.
#include <stdio.h>
int main()
{
int unit;
float amount, totalAmount, surCharge;
printf("Enter the number of units used: ");
scanf("%d", &unit);
if(unit <= 200)
{
amount = unit * 0.80;
}
else if(unit <= 300)
{
amount = 100 + ((unit-200) * 0.90);
}
else if(unit >= 350)
{
amount = 110 + ((unit-150) * 1.00);
}
if(amount>400){
surCharge = amount * 0.15;
}
totalAmount = amount + surCharge;
printf("Bill = Rs. %.2f", totalAmount);
return 0;
}
Comments
Leave a comment