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 the 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 total amount is charged. Read the names of users and number of units consumed and print out the charges with names.
Runtime Input :
100
500
Output :
Starting Reading: 100
Last Reading: 500
Unit Consumed: 400
Total Cost: 517.50
#include <stdio.h>
int main()
{
char name[100];
float unit_used, amount;
printf("Enter the user name: ");
scanf("%s", &name);
printf("Enter unit Consumed: ");
scanf("%f",&unit_used);
if(unit_used<125)
amount=100;
else if(unit_used<=200)
amount=unit_used*.80;
else if(unit_used<=300)
amount=(unit_used-200)*0.90+160;
else
if(unit_used>300)
amount=(unit_used-300)*1+250;
if(amount>=400)
amount=amount+amount*0.15;
printf("Name: %s\n", name );
printf("Charge: %5.2f",amount);
}
Comments
Leave a comment