by Dinesh Thakur Category: Classes in C++

 

unit tarrif

>100 RS.1.20 per unit
>200 RS.2 per unit
>300 RS.3 per unit
#include<iostream.h>
#include<conio.h>
class ebill
{
     private:
     int cno;
     char cname[20];
     int units;
     double bill;
     public:
                void get()
        {
                 cout<<"Enter Customer No,Name and No. of Units" <<endl;
                 cout<<"Enter Customer No : ";
                 cin>>cno;
                 cout<<"\nEnter Customer Name : ";
                 cin>>cname;
                 cout<<"\nEnter No. of Units used : ";
                 cin>>units;
         }
                void put()
         {
                cout<<"\nCustomer No is : "<<cno;
                cout<<"\nCustomer Name is : "<<cname;
                cout<<"\nNumber of Units Consumed : "<<units;
                cout<<"\nBill of Customer : "<<bill;
         }
                void calc()
        {
                if(units<=100)
                       bill=units*1.20;
               else if(units<=300)
                       bill=100*1.20+(units-100)*2;
               else
                       bill=100*1.20+200*2+(units-300)*3;
         }
};
             void main()
     {
             clrscr();
             ebill p1;
             p1.get();
             p1.calc();
             p1.put();
             getch();
      }

Find Electricity Bill Of A Person

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content







Popular Article