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

c++ Employee Class. Write a class named Employee, with the class declaration in

ID: 669235 • Letter: C

Question

c++

Employee Class. Write a class named Employee, with the class declaration in a file called Employee.h and the implementation in a file called Employee.cpp. The class should have the following data members:

name – A string that holds the employee’s name

idNumber – An int variable that holds the employee’s ID number

department – a string that holds the name of the department where the employee works

position – A string that holds the employee’s job status

The class must have the following constructors:

A constructor that accepts the following values as arguments and assigns them to the appropriate member variables: employee’s name, employee’s ID number, department and position.

A constructor that accepts the following values as arguments and assigns them to the appropriate member variable: employee’s name, employee’s ID number. The department and position fields should be assigned an empty string (“ “).

A default constructor that assigns empty string (“”) to the name, department and position member variables and 0 to the idNumber member variable.

Write the appropriate mutator functions that store values in these member variables and accessor functions that return the values in these member variables. Once you have written the class, write a separate program that creates 3 instances of the Employee class. Each instance of the class should use a different constructor than the other 2 objects (so all three constructors must be used). Main should use a function called displayEmployee that has one parameter which is a pointer to a constant Employee object. Main will call the function 3 times to display the information for each of the 3 instances of the Employee class.

void displayEmployee(Employee* const e);

The output of the program must be in the form of a table

C:Windowslsystem321cmd.exe Name ID Number Department Position Susan Me yers Mark Jones oy Rogers Press any key to continue 47899 39119 81774 Accounting IT Manufacturing Vice President Programmer Engineer

Explanation / Answer

//Employee.h

# include <iostream>
using namespace std;

class Employee
{
   public:
string name; // – A string that holds the employee’s name
int idNumber; //– An int variable that holds the employee’s ID number
string department;// – a string that holds the name of the department where the employee works
string position; //– A string that holds the employee’s job status  
Employee(string n, int ID, string d, string p);
Employee(string n, int ID);
Employee();

void setName(string nam);
void setID(int ID);
void setDepartment(string d);
void setposition(string p);
string getName(string nam);
int getID(int ID);
string getDepartment(string d);
string getposition(string p);
};//Employee.cpp

#include "Employee.h"
# include <iostream>
using namespace std;

void displayEmployee(Employee e);
Employee::Employee(string n, int ID, string d, string p)
{
   name=n;
   idNumber=ID;
   department=d;
   position=p;
}
Employee::Employee(string n, int ID)
{
   name=n;
   idNumber=ID;
   department="";
   position="";
}

Employee::Employee()
{
   name="";
   idNumber=0;
   department="";
   position="";
}
void Employee::setName(string nam)
{
   name=nam;
}
void Employee::setID(int ID)
{
   idNumber=ID;
}

void Employee::setDepartment(string d)
{
   department=d;
}

void Employee:: setposition(string p)
{
   position=p;
}

string Employee:: getName(string nam)
{
   return name;
}
int Employee::getID(int ID)
{
   return idNumber;
}
string Employee:: getDepartment(string d)
{
   return department;
}

string Employee:: getposition(string p)
{
   return position;
}

int main()
{
   Employee e1;
   Employee e2("Jhonny cartz",12314);
   Employee e3("Tim Davidson",34671,"Consulting","Vice President");
   cout<<"Name Id number Department Position ";

   displayEmployee(e1);
    cout<<" ";
   displayEmployee(e2);
   cout<<" ";
   displayEmployee(e3);
   return 0;
}
void displayEmployee(Employee e)
{
   cout<<e.name<<" "<<e.idNumber<<" "<<e.department<<" "<<e.position;
}

Output:

Name Id number Department Position
0
Jhonny cartz 12314
Tim Davidson 34671 Consulting Vice President
--------------------------------
Process exited after 0.05316 seconds with return value 0
Press any key to continue . . .

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote