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

C++, Microsoft Visual Studio Write a class named Employee that has the following

ID: 3696115 • Letter: C

Question

C++, Microsoft Visual Studio

Write a class named Employee that has the following member variables:

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 emplyees's job title.

The class should have the following constructors:

1. 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.

2. A constructor that accepts the following values as arguments and assigns them to the appropriate member variables: emplyee name and ID number. The department and position fields should be assigned an empty string(" ").

3. A default constructor that assigns empmty strings (" ")to the name, department, and position member variables, and 0 to the idNumber member variable.

Write 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 three Employee objects to hold the folowing data.

NAME (Susan Meyers, Mark Jones, Joy Rogers)

ID Number(47899, 39199, 81774)

Department(Accounting, IT, Manufactoring)

Position (Vice President, Programmer, Engineer)

The program should store this data in the three objects and then display the data for each employee on the screen.

//I am having a really tough time with this one. If you can explain what you are doing, and why you are doing it THAT would be an incredible help!!!

Explanation / Answer

Employee.h

#ifndef EMPLOYEE_H
#define EMPLOYEE_H

#include <string>
using std::string;

class Employee
{
   private:
string name;
int id;
string department;
string title;
   public:
Employee(string name, int id,string department,string title);
Employee(string name, int id);
Employee();
  
void set_name(string name);
void set_id(int id);
void set_department(string department);
void set_title(string title);

string get_name() const;
int get_id() const;
string get_department() const;
string get_title() const;

void print() const;


};
#endif

______________________________________________________________________________

Employee.cpp

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

Employee:: Employee(string name, int id,string department,string title)
{
this -> name = name;
this -> id = id;
this -> department = department;
this -> title = title;
}
Employee:: Employee(string name, int id)
{
this -> name = name;
this -> id = id;
this -> department = " ";
this -> title = " ";
}
Employee:: Employee()
{
this -> name = " ";
this -> id = 0;
this -> department = " ";
this -> title = " ";
}

void Employee :: print() const
{
cout << "Name: " << name << ' '
<< "Id : " << id << ' '
<< "Department : " << department << ' '
<< "Title : " << title << endl;
}
void Employee::set_name(string name)
{
name = name;
}

void Employee::set_id(int id)
{
id = id;
}

void Employee::set_department(string department)
{
department = department;
}

void Employee::set_title(string title)
{
title = title;
}


string Employee::get_name() const
{
return name;
}

int Employee::get_id() const
{
return id;
}

string Employee::get_department() const
{
return department;
}

string Employee::get_title() const
{
return title;
}

_________________________________________________________________________________

Main.cpp

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

int main()
{
Employee e("Susan Meyers",47899,"Accounting","Vice President");
Employee e1("Mark Jones",39199," IT","Programmer");
   Employee e2("Joy Rogers",81774,"Manufactoring","Engineer");

e.print();
e1.print();
e2.print();
return 0;
}

______________________________________________________________________________

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