Write a program to create electricity bill

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<iomanip.h>
const fixed =80;
void main()
{
   char name[20];
   long units,prev,curr;
   float tax,amount,total, slab30,slab100,slab200,slab300,slab400;
   clrscr();
   cout<<"\nEnter the name of the customer:";
   cin>>name;
   cout<<"\nEnter the current reading:";
   cin>>curr;
   cout<<"\nEnter the previous reading:";
   cin>>prev;
   units=curr-prev;
   if(units<=0)
   {
      cout<<"\nInvalid input";
      getch();
      exit(0);
   }
   slab30=30*1.85;
   slab100=slab30+(70*2.90);
   slab200=slab100+(100*3.60);
   slab300=slab200+(100*4.10);
   slab400=slab300+(100*4.35);
   if(units>=0 && units<=0)
      amount=units*1.85;
      else if(units<=100)
     amount=slab30+(units-30)*2.90;
       else if(units<=200)
          amount=slab100+(units-100)*3.60;
        else if(units<=300)
           amount=slab200+(units-200)*4.10;
              else if(units<=400)
            amount=slab300+(units-300)*4.35;
              else
                 amount=slab400+(units-400)*4.65;
   tax=(amount+fixed)*0.05;
   total=tax+amount;
   cout<<"     ELECTRICITY BILL             "<<endl;
   cout<<"------------------------------------------"<<endl;;
   cout<<"Name :"<<setw(5)<<name<<endl;
   cout<<"Previous Reading:"<<setw(5)<<prev<<endl;
   cout<<"Current Reading :"<<setw(5)<<curr<<endl;
   cout<<"Units Consumer  :"<<setw(5)<<units<<endl;
   cout<<"setprecision(2)"<<endl;
   cout<<"------------------------------------------"<<endl;;
   cout<<"Fixed Amount    :"<<setw(5)<<fixed<<endl;
   cout<<"Bill Amount     :"<<setw(7)<<amount<<endl;
   cout<<"Tax             :"<<setw(12)<<tax<<endl;
   cout<<"Net Bill Amount :"<<setw(9)<<total;
   getch();
}

No comments:

Post a Comment