Write a program in C to calculate and print the Electricity bill of a given customer.

 TASK-

Write a program in C to calculate and print the Electricity bill of a given customer. The customer id and unit consumed by the user should be taken from the keyboard and display the total amount to pay to the customer. The charge are as follow.

UnitCharge/unit
upto 199@1.20
200 and above but less than 400@1.50
400 and above but less than 600@1.80
600 and above@2.00

If bill exceeds Rs. 400 then a surcharge of 15% will be charged and the minimum bill should be of Rs. 100/-

 Expected Output : 

Customer IDNO :1001 
unit Consumed :800 
Amount Charges @Rs. 2.00 per unit : 1600.00 
Surcharge Amount : 240.00 
Net Amount Paid By the Customer : 1840.00


    LETS BEGIN THE CODING:✔






CODE:

#include<stdio.h>
#include<stdlib.h>

int main(){
//Initialization of variables.

int id,units;
float bill,net_bill,surchage=0,charge;

        printf("Enter your Id ");  //Taking Required inputs
scanf("%d",&id);
printf("\nEnter the amount of consumed units " );
scanf("%d",&units);

      //Here the working begins...
if (units<199) 
{
charge=1.20;
bill=units*1.20;
  if (bill<100) // We are asked for this condition minimum bill should be at least 100
  {
  
  printf("\n The minimum bill should be 100\n So sorry can't generate bill page !");
  exit(0);
}
}
else if (units>=200&&units<400)
{
bill=units*1.50;
charge=1.50;
}
else if (units>=400&&units<600)
{
charge=1.80;
bill=units*1.80;
}
else if (units>=600)
{
bill=units*2;
charge=2.00;
}
if (bill>400) // The person having Bill > 400 have to pay surcharge of 15% of bill
{
surchage=bill*0.15;
net_bill=bill+surchage;
}
else
{
net_bill=bill;
}
//Generating the table..

printf("\nCustomer ID NO : %d \nunit Consumed : %d\nAmount Charges @Rs. %0.2f per unit : %0.2f \nSurchage Amount : %0.2f \nNet Amount Paid By the Customer : %0.2f",id,units,charge,bill,surchage,net_bill);

getchar();
return 0;
}

OUTPUT:




NEED WORK PRODUCE WORK

My name is Abdul Rehman I am from Pakistan. I am doing BS in Computer and information sciences. Currently, I am creating these blogs to help students of computer sciences all over the world..

Post a Comment (0)
Previous Post Next Post