Answer to Question #173450 in C++ for VARUN

Question #173450

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.

input

1001

charlie

dubai

12000

output

1001

charlie

dubai

14400


1
Expert's answer
2021-03-21T06:36:55-0400
#include <iostream>
#include <string>
 
using namespace std;
 
class Employee
{
public:
	void GetEmpDetails(int num, string name, string dep, double sal);
	double Calculate_DA();
	void display();
private:
	int emp_number;
	string emp_name;
	string department;
	double salary;
	double net_salary;
};
 
void Employee::GetEmpDetails(int num, string name, string dep, double sal)
{
	emp_name = name;
	emp_number = num;
	department = dep;
	salary = sal;
}
 
double Employee::Calculate_DA()
{
	net_salary = salary * 1.2;
	return net_salary;
}
 
void Employee::display()
{
	cout << "Employee number is " << emp_number << endl;
	cout << "Employee name is " << emp_name << endl;
	cout << "Department is " << department << endl;
	cout << "Salary is " << Calculate_DA() << endl;
}
 
int main()
{
	Employee Bill;
	int num = 0;
	string name;
	string dep;
	double sal = 0;
	cout << "Enter employee details (number name department salary): ";
	cin >> num >> name >> dep >> sal;
	Bill.GetEmpDetails(num, name, dep, sal);
	cout << endl;
	Bill.display();
	return 0;
}

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