Answer to Question #328731 in C++ for Florence

Question #328731

Write a C++ program by creating an 'Employee' having the following functions and print the



final salary.



1 - 'getInfo()' which takes the salary, number of hours of work per day of employee as



parameters



2 - 'AddSal()' which adds $10 to the salary of the employee if it is less than $500.



3 - 'AddWork()' which adds $5 to the salary of the employee if the number of hours of work per



day is more than 6 hours.

1
Expert's answer
2022-04-14T08:04:41-0400
class Employee
{
public:
	int salary;
	int hours_of_work;


	Employee(int s, int h_o_w) : salary(s), hours_of_work(h_o_w) {}


	void getInfo()
	{
		std::cout << "Salary - " << salary << std::endl;
		std::cout << "The number of hours of work per day - " << hours_of_work << std::endl;
	}


	void AddSal()
	{
		if (salary < 500)
		{
			salary += 10;
		}
	}


	void AddWork()
	{
		if (hours_of_work > 6)
		{
			salary += 5;
		}
	}
};

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