C program that print electricity bill of a customer Posted by Samath Last Updated: January 02, 2017 560

Write a C program to print the Electricity bill of a given customer.The program should read customer ID number, name and unit consumed by the customer and print the total amount to pay. The charge are as follow:

if unit < 200 then charge are \$1.20 per unit
if unit >= 200 but < 400 then charge are \$1.60 per unit
if unit >= 400 but < 600 then charge are \$2.00 per unit
if unit >= 600 then charge are \$2.50 per unit
If bill exceed \$ 300 then a surcharge of 15% will be charged and minimum bill should be of \$25.

Code:

```#include<stdio.h>
#include<string.h>
#include<conio.h>

int main()
{

int customer_number, unit_con;
float charge,surcharge=0, amt,total_amt;
char name;

printf("Enter the customer ID Number: ");
scanf("%d",&customer_number);

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

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

if (unit_con <200 )
charge = 1.20;
else	if (unit_con>=200 && unit_con<400)
charge = 1.60;
else if (unit_con>=400 && unit_con<600)
charge = 2.00;
else
charge = 2.50;
amt = unit_con*charge;
if (amt>300)
surcharge = amt*15/100.0;
total_amt = amt+surcharge;
if (total_amt  < 25)
total_amt =25;

printf("\n\t\t\tElectricity Bill\n\n");
printf("Customer ID Number                         :\t%5d",customer_number);
printf("\nCustomer Name                       :\t%s",name);
printf("\nunit Consumed                       :\t%5d",unit_con);
printf("\nAmount Charges \$ %4.2f  per unit :\t%8.2f",charge,amt);
printf("\nSurchage Amount                     :\t%8.2f",surcharge);
printf("\nNet Amount Paid By the Customer     :\t%8.2f",total_amt);

return 0;
}```