Search This Blog

Sunday 1 May 2016

Wrie a Program to find simple payroll system using single inheritance

Practical - 24


#include<iostream>
using namespace std;
class employee
{
   public:
     int eno;
     char name[20],des[20];
     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 employee
{
     float bp,hra,sb,leave,np;
   public:
     void get1()
     {
              cout<<"Enter the basic pay:";
              cin>>bp;
              cout<<"Enter the Human Resource Allowance:";
              cin>>hra;
              cout<<"Enter the Special Bonus :";
              cin>>sb;
              cout<<"Enter the Leave Deduction rs:";
              cin>>leave;
     }
     void calculate()
     {
              np=bp+hra+sb-leave;
     }
     void display()
     {
              cout<<eno<<"\t"<<name<<"\t"<<des<<"\t"<<bp<<"\t"<<hra<<"\t"<<sb<<"\t"<<leave<<"\t"<<np<<"\n";
     }
};

int main()
{
    int i,n;
    salary s[10];

    cout<<"Enter the number of employee:";
    cin>>n;
    for(i=0;i<n;i++)
    {
              s[i].get();
              s[i].get1();
              s[i].calculate();
    }
    cout<<"\ne_num \t e_name\t des \t bp \t hra \t sb \t leave \t total \n";
    for(i=0;i<n;i++)
    {
              s[i].display();
    }
    return 0;
}

No comments:

Post a Comment