0
17kviews
An electric power distribution company charges its domestic consumer as follows:
Consumption Units Rate of Charge
0-200 0.50 per unit
201-400 Rs. 100 plus Rs. 0.65 per unit excess of 200
401-600 Rs. 230 plus Rs. 0.85 per unit excess of 400
601-above Rs. 390 plus Rs. 1.00 per unit excess of 600

Program should read the units consumed for a customer and calculate the total bill

1 Answer
1
2.0kviews

Program:

#include<stdio.h>
#include<string.h>
#include<conio.h>
int main(){
int cust_no, unit_con;
float charge,surcharge=0, amt,total_amt;
char nm[25];

printf("\nEnter the customer Name :");
scanf("%s",nm);

printf("\nEnter the unit consumed by customer:");
scanf("%d",&unit_con);

if (unit_con <200 ){
charge = 0.50;
surcharge = 0;
amt = unit_con*charge;
total_amt = amt+surcharge;
}
elseif (unit_con>=200 && unit_con<400) {
charge = 0.65;
surcharge = 100;
amt = unit_con*charge;
total_amt = amt+surcharge;
}
else if (unit_con>=400 && unit_con<600){
charge = 0.85;
surcharge = 230;
amt = unit_con*charge;
total_amt = amt+surcharge;
}
else{
charge = 1.00;
surcharge = 390;
amt = unit_con*charge;
total_amt = amt+surcharge;
}
printf("\n\t\t\tElectricity Bill\n\n");
printf("\nCustomer Name:\t%s",nm);
printf("\nunit Consumed:\t%5d",unit_con);
printf("\nAmount Charges per unit:\t%8.2f",charge,amt);
printf("\nSurcharge Amount:\t%8.2f",surcharge);
printf("\nNet Amount Paid By the Customer:\t%8.2f",total_amt);
getch();
}//main ends


Output:

Enter the customer Name: DIEGO COSTA

Enter the unit consumed by customer: 420

Amount Charges per unit: 0.85

Surcharge Amount: 230

Please log in to add an answer.