(Program) a. Construct a class definition to represent an employee of a company.
ID: 3659449 • Letter: #
Question
(Program) a. Construct a class definition to represent an employee of a company. Each employee is defined by an integer ID number, a double-precision pay rate, and the maximum number of hours the employee should work each week. The class should provide these services: the capability to enter data for a new employee, the capability to change data for a new employee, and the capability to display existing data for a new employee. b. Include the class definition created for Exercise a in a working C++ program that asks the user to enter data for three employees and then displays the entered data.Explanation / Answer
#include #include using namespace std; class Employee{ int ID; double pay_rate; int maxhour; public: //constructors Employee();//default constructor Employee(int, double,int);//constuctor that sets all 3 private memebers //mutators void setID(int); void setSalary(double); void setMaxHour(int); //accessors int getID(); double getSalary(); int getMaxHour(); }; Employee::Employee(){ ID=1; pay_rate=7.50; maxhour=0; } Employee::Employee(int id,double pay,int maxhr){ ID=id; setSalary(pay); setMaxHour(maxhr); } void Employee::setID(int id){ID=id;} void Employee::setSalary(double pay){ if(pay>0){ pay_rate=pay; } else{ coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.