C++ Program:
File: Employee.h
#ifndef EMPLOYEE_H_INCLUDED
#define EMPLOYEE_H_INCLUDED
#include<iostream>
#include<string>
using namespace std;
//Class definition
class Employee
{
private:
//Data members
string name;
int idNumber;
string department;
string position;
public:
//Constructors
Employee(string n, int id, string dept, string
pos);
Employee(string n, int id);
Employee();
//Getter methods
string getName();
int getIdNumber();
string getDepartment();
string getPosition();
//Setter methods
void setName(string);
void setIdNumber(int);
void setDepartment(string);
void setPosition(string);
};
#endif // EMPLOYEE_H_INCLUDED
File: Employee.cpp
#include<iostream>
#include<string>
#include "Employee.h"
using namespace std;
//Setter Methods
void Employee::setPosition(string p)
{
position = p;
}
void Employee::setDepartment(string d)
{
department = d;
}
void Employee::setIdNumber(int id)
{
idNumber = id;
}
void Employee::setName(string n)
{
name = n;
}
string Employee::getPosition()
{
return position;
}
string Employee::getDepartment()
{
return department;
}
int Employee::getIdNumber()
{
return idNumber;
}
string Employee::getName()
{
return name;
}
//Default Constructor
Employee::Employee()
{
name = "";
idNumber = 0;
department = "";
position = "";
}
//Arg-Constructor
Employee::Employee(string n, int id)
{
name = n;
idNumber = id;
department = "";
position = "";
}
//Arg-Constructor
Employee::Employee(string n, int id, string dept, string pos)
{
name = n;
idNumber = id;
department = dept;
position = pos;
}
File: main.cpp
#include <iostream>
#include <iomanip>
#include <string>
#include "Employee.h"
using namespace std;
//Main method
int main()
{
//Employee array
Employee emps[3];
//First object
Employee e1("Jenny Jacobs", 8890, "Accounting",
"President");
emps[0] = e1;
//Second object
Employee e2("Myron Smith", 7571);
emps[1] = e2;
emps[1].setDepartment("IT");
emps[1].setPosition("Programmer");
//Setting values for third employee
object
emps[2].setName("Chris Raines");
emps[2].setIdNumber(6873);
emps[2].setDepartment("Manufacturing");
emps[2].setPosition("Engineer");
//Printing header
cout << endl << left <<
setw(20) << "Name" << left << setw(20) <<
"Id Number" << left << setw(20) << "Department"
<< left << setw(20) << "Position" << endl
<< endl;
//Printing data
for(int i=0; i<3; i++)
{
cout << left
<< setw(20) << emps[i].getName() << left <<
setw(20) << emps[i].getIdNumber() << left <<
setw(20) << emps[i].getDepartment() << left <<
setw(20) << emps[i].getPosition() << endl;
}
cout << endl << endl;
return 0;
}
______________________________________________________________________________
Sample Run:
Create a c++ code and answer number 1 Homework Ch. 13 - Employee Class 30 points...
Using C++, 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 employee's job title. The class should have the following constructors: A constructor that accepts the following values as arguments and assigns them to the appropriate member variables: employee's name,...
It must be C++ Chapter 13 Programming Challenge 2: Employee Class. See instruction: Chapter 13 Programming Challenge 2 Employee Class.pdf Program Template: // Chapter 13, Programming Challenge 2: Employee Class #include <iostream> #include <string> using namespace std; // Employee Class Declaration class Employee { private: string name; // Employee's name int idNumber; // ID number string department; // Department name string position; // Employee's position public: // TODO: Constructors // TODO: Accessors // TODO: Mutators }; // Constructor #1 Employee::Employee(string...
Write a C++ program Write a class named Employee that has the following member variables: name A string that holds the employee name idNumber An int to hold employee id number department A string to hold the name of the department position A string to hold the job position The class will have three constructors: 1. A constructor that accepts all the internal data such as: Employee susan("Susan Meyers", 47899, "Accounting", "Vice President"); 2. A constructor that accepts some of...
Create a C# Console program. Add a class named Employee that has the following public fields: • Name. The name field references a String object that holds the employee’s name. • IDNumber. The IDNumber is an int that holds the employee’s ID number. • Department. The department field is a String that holds the name of the department where the employee works. • Position. The position field is a String that holds the employee’s job title. Once you have written...
Design and write a class named Employee that inherits the Person class from the previous exercise and holds the following additional data: ID number, department and job title. Once you have completed the Employee class, write a Python program that creates three Employee objects to hold the following data: Name ID Number Department Job Title Phone Susan Meyers 47899 Accounting Vice President 212-555-1212 Mark Jones 39119 IT Programmer 212-555-2468 Joy Rogers 81774 Operations Engineer 212-555-9753 The Python program should store...
Write a code in C++ by considering the following conditions :- Tasks :- 1. Create a class Employee (with member variables: char * name, int id, and double age). 2. Create a constructor that should be able to take arguments and initialize the member variables. 3. Create a copy constructor for employee class to ensure deep copy. 4. Create a destructor and de allocate the dynamic memory. 5. Overload the assignment operator to prevent shallow copy and ensure deep copy....
1. Write a class named Employee that holds the following data about an employee in attributes: name, ID number, department, and job title. (employee.py) 2. Create a UML diagram for Employee class. (word file) 3. Create a program that stores Employee objects in a dictionary. Use the employee ID number as the key. (employee_App.py) The program should present a menu that lets the user perform the following actions: ✓ Look up an employee in the dictionary ✔ Add a new...
Write a Java class named Employee to meet the requirements described in the UML Class Diagram below: Note: Code added in the toString cell are not usually included in a regular UML class diagram. This was added so you can understand what I expect from you. If your code compiles cleanly, is defined correctly and functions exactly as required, the expected output of your program will solve the following problem: “An IT company with four departments and a staff strength...
Part (A) Note: This class must be created in a separate cpp file Create a class Employee with the following attributes and operations: Attributes (Data members): i. An array to store the employee name. The length of this array is 256 bytes. ii. An array to store the company name. The length of this array is 256 bytes. iii. An array to store the department name. The length of this array is 256 bytes. iv. An unsigned integer to store...
IN JAVADesign a Payroll class with the following fields:• name: a String containing the employee's name• idNumber: an int representing the employee's ID number• rate: a double containing the employee's hourly pay rate• hours: an int representing the number of hours this employee has workedThe class should also have the following methods:• Constructor: takes the employee's name and ID number as arguments• Accessors: allow access to all of the fields of the Payroll class• Mutators: let the user assign values...