Create & display payslip - C++ Program

Q. Write a C++ program to define a class employee having members Emp-id, Emp-name, basic salary and functions accept() and display(). Calculate DA=25% of basic salary, HRA=800, I-tax=15% of basic salary. Display the payslip using appropriate output format.


Following program is defining a class Employee and calculating DA, HRA, tax of his/her basic salary and also displaying the payslip of an employee.

using namespace std;

class Employee
        int eid;
        char ename[100];
        float basic_salary, hra, da, i_tax, net_salary;

        void accept_details()
                cout<<"\n Enter Employee Id : ";
                cout<<"\n Enter Employee Name : ";
                cout<<"\n Enter Basic Salary : ";

                hra = 800;
                da = 0.25 * basic_salary;
                i_tax = 0.15 * basic_salary;
                net_salary = basic_salary + da + hra - i_tax;
        void display_details()
                cout<<"\n ----------------------- ";
                cout<<"\n Employee Id        : "<<eid;
                cout<<"\n Employee Name  : "<<ename;
                cout<<"\n Basic Salary         : "<<basic_salary;
                cout<<"\n HRA                      : "<<hra;
                cout<<"\n DA                        : "<<da;
                cout<<"\n I-Tax                      : "<<i_tax;
                cout<<"\n Net Salary             : "<<net_salary;
int main()
        Employee e;
        return 0;


employee hra da net