Algorithm
1. Declare all values
2. Taking Customer ID
3. Taking Units Consumed by User
4. Making Conditions
5. Printing Total Bill In Proper Format
Code
#include <stdio.h>
void main()
{
int custid, conu;
float chg, surchg=0, gramt,netamt;
char x;
printf("Input Customer ID :");
scanf("%d",&custid);
printf("Input the unit consumed by the customer : ");
scanf("%d",&conu);
if (conu <200 )
chg = 1.20;
else if (conu>=200 && conu<400)
chg = 1.50;
else if (conu>=400 && conu<600)
chg = 1.80;
else
chg = 2.00;
gramt = conu*chg;
if (gramt>300)
surchg = gramt*15/100.0;
netamt = gramt+surchg;
if (netamt < 100)
netamt =100;
printf("\nElectricity Bill\n");
printf("Customer IDNO :%d\n",custid);
printf("unit Consumed :%d\n",conu);
printf("Amount Charges @Rs. %4.2f per unit :%8.2f\n",chg,gramt);
printf("Surchage Amount :%8.2f\n",surchg);
printf("Net Amount Paid By the Customer :%8.2f\n",netamt);
}
Output
Input Customer ID :1
Input the unit consumed by the customer : 584
Electricity Bill
Customer IDNO :1
unit Consumed :584
Amount Charges @Rs. 1.80 per unit : 1051.20
Surchage Amount : 157.68
Net Amount Paid By the Customer : 1208.88
PS C:\Users\anmol\OneDrive\Desktop\Collage\Sem-1\C Projects>