Friday, 26 January 2018

To write a program to find out the payroll system using single inheritance. C++ GTU

#include<iostream>
using namespace std;

class emp
{
   public:
     int eno;
     string name,des;
     void get()
     {
              cout<<"Enter the employee number:";
              cin>>eno;
              cout<<"Enter the employee name:";
              cin>>name;
              cout<<"Enter the designation:";
              cin>>des;
     }
};

class salary:public emp
{
   float bp,hra,da,pf,np;
  
   public:
     void get1()
     {            
              cout<<"Enter the Basic pay:";
              cin>>bp;
              cout<<"Enter the Humen Resource Allowance:";
              cin>>hra;
              cout<<"Enter the Dearness Allowance :";
              cin>>da;
              cout<<"Enter the Profitablity Fund:";
              cin>>pf;
     }
     void calculate()
     {
              np=bp+hra+da-pf;
     }
     void display()
     {
              cout<<eno<<"\t"<<name<<"\t"<<des<<"\t"<<bp<<"\t"<<hra<<"\t"<<da<<"\t"<<pf<<"\t"<<np<<"\n";
     }
};

int main()
{
    salary s;
   
    s.get();
    s.get1();
    s.calculate();
   
    cout<<"\ne_no \te_name\t des \t bp \t hra \t da \t pf \t np \n";
    s.display();
    return 0;
}

No comments:

Post a Comment

It's time To increase blogging capability. To have a chance to contribute in digital world. Any Interested People who want to make t...