AIM:-Write a program to model employee class with appropriate data members and member               functions, and allow user to initialize data, calculate salary, and display basic detail of                   employee and display pay sleep.

input:-

 

#include<iostream>

#include<string.h>

using namespace std;

class employee

{

    

    int emp_code,exp,b_salary=0,da=0,hra=0,medical=0,sum=0;

    char emp_name[50],department[50],post[20];

    float pf=0,prof_tax=0,income_tax=0,gross_salary=0;

    

    public :

    

    void accept()

    {

        cout<<“enter emp_code:”;

        cin>>emp_code;

        cout<<“enter emp_name:”;

        cin>>emp_name;

        cout<<“enter department:”;

        cin>>department;

        cout<<“enter post:”;

        cin>>post;

        cout<<“enter experience:”;

        cin>>exp;

        cout<<“enter b_salay:”;

        cin>>b_salary;

    }

    

    void calculat()

    {

        da=b_salary*10/100;

        hra=b_salary*10/100;

        medical=b_salary*10/100;

        pf=b_salary*12/100;

        prof_tax=b_salary*5/100;

        income_tax=b_salary*10/100;

        

        sum=da+hra+medical+pfprof_taxincome_tax;

        gross_salary=b_salary+sum;

        

    }

    

    

    void display()

    {

        cout<<“\tpay sleep”;

        cout<<“\n—————————————————–“;

        cout<<“\n”<<post;

        cout<<“\n”<<department;

        cout<<“\n—————————————————–“;

        

        cout<<“\nb_salary da hra medical pf prof_tax income_tax gross_salary”;

        cout<<“\n”<<b_salary<<“\t\t”<<da<<“\t”<<hra<<“\t”<<medical<<“\t”<<pf<<“\t”<<prof_tax<<“\t”<<income_tax<<“\t”<<gross_salary;

        

    }

    

    

    

    

};

int main()

{

    employee emp;

    emp.accept();

    emp.calculat();

    emp.display();

    return 0;

}

output:-

enter emp_code:18

enter emp_name:dhaval

enter department:mscit

enter post:student

enter experience:2

enter b_salay:10000

pay sleep

—————————————————–

student

mscit

—————————————————–

b_salary  da     hra    medical   pf          prof_tax     income_tax            gross_salary

10000   1000  1000 1000        1200    500              1000                       12700

Advertisements