Answer to Question #312533 in C++ for Raian

Question #312533

Develop a program by creating an 'Employee' class 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-03-16T07:09:12-0400
#include <iostream>
using namespace std;




class Employee{
private:
	float salary;
	float numberHours;
public:
	//'getInfo()' which takes the salary, number of hours of work per day of employee as parameters
	void getInfo(){
		cout<<"Enter the salary: ";
		cin>>salary;
		cout<<"Enter the number of hours of work per day: ";
		cin>>numberHours;
	}
	// 'AddSal()' which adds $10 to the salary of the employee if it is less than $500.
	void AddSal(){
		if(salary<500){
			this->salary+=10.0;
		}
	}
	// 'AddWork()' which adds $5 to the salary of the employee if the number of hours of work per day is more than 6 hours.
	void AddWork(){
		if(numberHours>6){
			this->salary+=5.0;
		}
		cout<<"The final salary of the employee: "<<salary<<"\n\n";
	}
};




int main()
{


	Employee employee;
	employee.getInfo();
	employee.AddSal();
	employee.AddWork();


	system("pause");


	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