Answer to Question #173881 in C++ for P. Gokul

Question #173881

Declare the class Employee, consisting of data members are emp_number, emp_name, department, salary and net_salary. The member functions are GetEmpDetails() to accept information for an employee, Calculate_DA() to calculate DA=20% of salary and display() to display the information of a employee.


1
Expert's answer
2021-03-23T18:43:17-0400
class Employee
{
private:
    int emp_number;
    string emp_name;
    string Department;
    int salary;
    double net_salary;
    
public:
    void GetEmpDetails()
    {
        cout << "Enter employee number: ";
        cin >> emp_number;
        cin.ignore(32767, '\n');
        cout << "Enter employee name: ";
        getline (cin, emp_name);
        cout << "Enter employee Department: ";
        getline (cin, Department);
        cout << "Enter employee salary: ";
        cin >> salary;
        cin.ignore(32767, '\n');
    }
    
    void Calculate_DA()
    {
        net_salary = salary * 0.8;
    }
    
    void display()
    {
        cout << "Employee number: " << emp_number << endl;
        cout << "Employee name: " << emp_name << endl;
        cout << "Employee Department: " << Department << endl;
        cout << "Employee salary: " << salary << endl;
        cout << "Employee net salary: " << net_salary << endl;
    }
};

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS