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.
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;
}
};
Comments
Leave a comment