Friday, July 22, 2011

C Progarm to calculate Electric Bill



#include<stdio.h>
#include<conio.h>
void main()
{
   int cno,pmr,cmr,cu;
   float total;
   char sec;
   char cname[10];
   clrscr();
   printf(" ENTER the SECTOR     : ");
   scanf("%c",&sec);
   printf(" Enter customer name   : ");
   scanf("%s",&cname);
   printf(" Enter customer number  :     ");
   scanf("%d",cno);
   printf(" Enter the previous units  : ");
   scanf("%d",&pmr);
   printf(" Enter the current units  : ");
   scanf("%d",&cmr);
   cu=cmr-pmr;
   if(sec == 'a')
   {
      if(cu>300)
      total=cu*2.00;
if(cu>200  && cu<=300)
total=cu*1.50;
 if(cu>100 && cu<=200)
 total=cu*1.00;
   if(cu<=100)
   total=cu*0.50;
   }
   if(sec=='i')
   {
      if(cu>300)
      total=cu*4.00;
if(cu>200  && cu<=300)
total=cu*3.00;
if(cu>100 && cu<=200)
 total=cu*2.00;
   if(cu<=100)
   total=cu*1.00;
   }
    if(sec == 'a')
   {
      if(cu>300)
      total=cu*2.00;
if(cu>200  && cu<=300)
total=cu*1.50;
 if(cu>100 && cu<=200)
 total=cu*1.00;
   if(cu<=100)
   total=cu*0.50;
   }
    if(sec == 'd')
   {
      if(cu>300)
      total=cu*2.00;
if(cu>200  && cu<=300)
total=cu*1.50;
 if(cu>100 && cu<=200)
 total=cu*1.00;
   if(cu<=100)
   total=cu*0.50;
   }
   printf("\n Customer name   :   %s ",cname);
   printf("\n Customer number :   %d",cno);
   printf("\n Previous Units  :   %d",pmr);
   printf("\n Current Units   :   %d",cmr);
   printf("\n Category        :   %c",sec);
   printf("\n Consumed Units  :   %d",cu);
   printf("\n Electric Bill   :   %f",total);
   getch();
   }











2 comments:

  1. void main()
    {
    int units,sno,cread,pread=0;
    float amount,total,surcharge,tax;
    clrscr();
    printf("enter the sno");
    scanf("%d",&sno);
    if(sno==1234)
    {
    printf("custmour name is vamsi\n");
    printf("enter the cread");
    scanf("%d",&cread);
    units=cread-pread;
    }
    else
    {
    printf("serial number is invalid enter correct serial number");
    getch();
    return ;
    }
    if (units==0)
    {
    printf("minimum bill is Rs.25/-");
    getch();
    }
    else if(units>0&&units<=50)
    {
    amount=(units*0.75);
    }
    else if(units>50&&units<=100)
    {
    amount=(units-50)*0.85+(50*0.75);
    }
    else if(units>100&&units<=200)
    {
    amount=(units-100)*1.50+(50*0.85)+(50*0.75);
    }
    else if(units>200&&units<=300)
    {
    amount=(units-200)*2.20+(100*1.50)+(50*0.75)+(50*0.85);
    }
    else if(units>300)
    {
    amount=(units-300)*3.00+(100*1.50)+(100*2.20)+(50*0.75)+(50*0.85);
    }
    {
    printf("amount=%f\n",amount);
    tax=(10*amount)/100;
    printf("tax=%f\n",tax);
    surcharge=(20*amount)/100;
    printf("surcharge=%f \n",surcharge);
    total=amount+tax+surcharge;
    printf("total=%f \n",total);
    getch();
    }
    }

    ReplyDelete