I\'m having trouble figuring out how to do the following things to my code... 1)
ID: 3542518 • Letter: I
Question
I'm having trouble figuring out how to do the following things to my code...
1)Setup: Initializes m_firstName, m_lastName, and m_payPerHour with the parameters passed to
it. Sets m_activeEmployee to true (i.e., the employee is a current employee).
2)GetName: Returns the first and last names (m_firstName and m_lastName) separated by a
blank.
3)GetIsActive: Returns the value of m_activeEmployee.
4)LayOff: Sets the value of m_activeEmployee to false (i.e., the employee is a current employee).
5)Output: Displays a current employee record something like this,
Explanation / Answer
#include<iostream>
#include<iomanip>
using namespace std;
#ifndef _EMPLOYEE
#define _EMPLOYEE
#include <string>
using namespace std;
class Employee
{
public:
void Setup( const string& first, const string& last, float pay )
{
m_firstName = first;
m_lastName = last;
m_payPerHour = pay;
m_activeEmployee = true;
}
string GetName()
{
return m_firstName + " " + m_lastName;
}
bool GetIsActive()
{
return m_activeEmployee;
}
void LayOff()
{
m_activeEmployee = false;
}
void Output()
{
cout << GetName() << ", PAY :$" << fixed << setprecision(2) << m_payPerHour << endl;
}
private:
string m_firstName;
string m_lastName;
float m_payPerHour;
bool m_activeEmployee;
};
#endif
int main()
{
Employee E1;
E1.Setup("Ashok","Kumar",6);
Employee E2;
E2.Setup("Sujatha","Jan",5);
E1.Output();
E2.Output();
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.