Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

class employee //Line 1 { //Line 2 public: //Line 3 employee(); //Line 4 employe

ID: 3571999 • Letter: C

Question

class employee                                                //Line 1
{                                                                      //Line 2
public:                                                                         //Line 3
employee();                                                     //Line 4
employee(string, int, double);                         //Line 5
employee(int, double);                                    //Line 6
employee(string);                                            //Line 7

void setData(string, int, double);                    //Line 8
void print() const;                                           //Line 9
void updateSalary(double x);                                     //Line 10
int getNumOfServiceYears() const;               //Line 11
double getSalary() const;                                //Line 12

private:                                                            //Line 13
string name;                                                     //Line 14
int numOfServiceYears;                                 //Line 15
double salary;                                                  //Line 16
};                                                                     //Line 17

a.) Write the definition of the function setData so that the instance variables are set according to the parameters.

b.) Write the definition of the function print to output the values of the instance variables.

c.) Write the definition of the function updateSalary to update the value of the instance variable salary by adding the value of the parameter.

d.) Write the definition of the function getNumOfServiceYears to return the value of the instance variable numOfServiceYears.

Explanation / Answer

a.) Write the definition of the function setData so that the instance variables are set according to the parameters.

void employee::setData(string xyz, int numyear, double sal)
{
name=xyz;
numOfServiceYears=numyear;
salary= sal;

}

-----------------------------------------------------------------------------------------------------------

b.) Write the definition of the function print to output the values of the instance variables.

void employee::print() const
{
cout<<"Name is: "<< name << "Number of Service Year"<<numOfServiceYears<<" Salary is"<<salary;

}

------------------------------------------------------------------------------------------------------------------

c.) Write the definition of the function updateSalary to update the value of the instance variable salary by adding the value of the parameter.

void employee::updateSalary(double x)
{
salary=salary+x;

}

-------------------------------------------------------------------------------------------------------------------

d.) Write the definition of the function getNumOfServiceYears to return the value of the instance variable numOfServiceYears

int employee::getNumOfServiceYears() const
{
return numOfServiceYears;

}

---------------------------------------------------------------------------------------------

If you have any query, please feel free to ask.

Thanks a lot.