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

Practice using inheritance Practice using polymorphism Practice using an STL con

ID: 3829442 • Letter: P

Question

Practice using inheritance

Practice using polymorphism

Practice using an STL container

Program should be in C++

I have written the .h file code with the help of Chegg, but in my project, its mentioned that I required .cpp file for every .h file. These are the files I required project6-main.cpp Employee.h Employee.cpp Cashier.h Cashier.cpp Manager.h Manager.cpp rubric6.tx. Ignore the files with bold, I am missing .cpp for every header file. While compiling I am getting many errors also, we are not required to mess with project6-main.cpp this file as it is a driver code and given by professor and we are not required to change anything. Can anyone look at my code and fix those error. I have also added input file to check the output. If more information required please let me know. Other details are motioned below.

For this project, you will write a complete C++ program to handle a staff directory and payroll. Extend the driver code located in project6-main.cpp. You need to declare an STL container named employees in the processInputs() function. Additionally, you need to write the Employee, Cashier and Manager classes. Also, you need to use inheritance and polymorphism appropriately. The Employee class needs to store the employee's name. Employees are paid minimum wage ($7.25) for 40 hours each week. The Cashier class needs to store the cashier name and their hourly wage. Cashiers are paid this hourly wage for 40 hours each week. The Manager class needs to store the manager's name, their ID and their weekly salary.
Additionally, add a comment identifying the polymorphic method call in project6-main.cpp.
You can use the following input files for this project:

DRIVER CODE // project6-main.cpp

My Work

File: Employee.h

#ifndef Included_Employee_H
#define Included_Employee_H

#include
using namespace std;

class Employee
{
private:
static const float NUM_WORK_HOURS = 40.0;
static const float MIN_WAGE_PER_HOUR = 7.25; // $7.25

protected:
string name;
float wagePerHour;
  
public:
Employee(string aName) : name(aName), wagePerHour(MIN_WAGE_PER_HOUR) { }

Employee(string aName, float aWagePerHour) : name(aName) {
if (aWagePerHour < MIN_WAGE_PER_HOUR) {
aWagePerHour = MIN_WAGE_PER_HOUR;
}
wagePerHour = aWagePerHour;
}

string getName() { return name; }

virtual void display() { cout << name << endl; }

virtual void payroll() {
cout << name << " $" << fixed << setprecision(2) << (wagePerHour * NUM_WORK_HOURS) << endl;
}
};

#endif // Included_Employee_H

File: Cashier.h

#ifndef Included_Cashier_H
#define Included_Cashier_H

#include <iostream>

#include "Employee.h"

using namespace std;

class Cashier : public Employee
{
public:
Cashier(string aName, float aWagePerHour) : Employee(aName, aWagePerHour) { }

virtual void display() {
cout << name << " (Cashier hourly wage: $" << fixed << setprecision(2) << wagePerHour << ")" << endl;
}
};

#endif // Included_Cashier_H

File: Manager.h

#ifndef Included_Manager_H
#define Included_Manager_H

#include

#include "Employee.h"

using namespace std;

class Manager : public Employee
{
private:
int managerId;
float wagePerWeek;

public:
Manager(string aName, int aManagerId, float aWagePerWeek) : Employee(aName), managerId(aManagerId) {
wagePerWeek = aWagePerWeek;
}

virtual void display() {
cout << name << " (Manager id: " << managerId << ", weekly wage: $" << fixed << setprecision(2) << wagePerWeek << ")" << endl;
}

virtual void payroll() {
cout << name << " $" << fixed << setprecision(2) << wagePerWeek << endl;
}
};

#endif // Included_Manager_H

INPUT (There re two input files)

input file 2:

other input file is large so i am attaching link to access that file (in Link assignment detail is also present)

https://drive.google.com/open?id=0B8OHmjK8INMndVV3QlBWdk5KeFE

OUTPUT

RUBRIC:

Explanation / Answer

#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h> // for exit()
#include <iomanip> // fixed, setprecision()

#include "Employee.h"
#include "Cashier.h"
#include "Manager.h"

using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using std::getline;
using std::ifstream;
using std::fixed;
using std::setprecision;

bool DEBUG = false; // toggles extra printing

const string DEFAULT_INPUT_FILENAME = "project6-testA.tab";

// Action characters in the input file
const char ADD_EMPLOYEE = 'E';
const char ADD_CASHIER = 'C';
const char ADD_MANAGER = 'M';
const char REMOVE = 'R';
const char PAYROLL = 'P';
const char FIND = 'F';
const char DISPLAY_ALL = 'D';

class Person{
protected:
string name;
double wage;
  
public:
map<string,Person> m;
virtual void add(Person p)
{
m.add(pair<string,Person>(p.name,p));
}
}

class Employee :: public Person{
public:
EmpLoyee(string n,double w=7.25):name(n),wage(w)
{
  
}
virtual void add(Employee e)
{
m.add(pair<string,Person>(e.name,e));
}
};
class Cashier :: public Person{
public:
Cashier(string n,double w=10.5):name(n),wage(w)
{
  
}
virtual void add(Cashier c)
{
m.add(pair<string,Person>(c.name,c));
}
};
class Manager :: public PerSson{
private:
int ID;
public:
Manager(int ID,string n,double w=19):name(n),wage(w)
{
  
}   
virtual void add(Manager m)
{
m.add(pair<string,Person>(m.name,m));
}
};


// Process the inputs in inputFilename
void processInputs( string inputFilename ){

// declare an STL container named employees here
  
// open file
ifstream fileStream;
fileStream.open( inputFilename.c_str() );

// verify the file is opened correctly
if( ! fileStream ){
cerr << "ERROR: Can not open input file " << inputFilename << "!" << endl;
exit(1);
}

cout << "Importing instructions from " << inputFilename << " ..." << endl;
  
char action = '';
  
// while there's more patients to process
// read in the action and make sure that we're not at the end of the file
while( fileStream >> action ){
if( DEBUG ){ cout << "action: " << action << endl; }
string name;
switch( action ){

case ADD_EMPLOYEE:
// get the employee's name from the file
fileStream >> name;
cout << "Adding employee " << name << endl;

Person p = new Employee(name);
p.add(p);
cout << endl;
if( DEBUG ){ displayAll( employees); }
break;
case ADD_CASHIER:
// get the employee's name from the file
fileStream >> name;
float hourlyWage;
fileStream >> hourlyWage;
cout << "Adding cashier " << name << endl;

Person p = new Cahier(name,hourlyWage);
p.add(p);
cout << endl;
if( DEBUG ){ displayAll( employees); }
break;
case ADD_MANAGER:
// get the employee's name from the file
fileStream >> name;
int id;
fileStream >> id;
float salary;
fileStream >> salary;
cout << "Adding manager " << name << endl;
  
Person p = new Person(name,id,salary);
p.add(p);
cout << endl;
if( DEBUG ){ displayAll( employees); }
break;
case REMOVE:
// get the employee's name from the file
fileStream >> name;
cout << "Removing " << name << endl;
map<string,Person>::iterator it;
it = m.find(name);
if(it == m.end())
{
cout << "Unable to remove " << name << endl;
}
break;
case PAYROLL:
payroll( employees );
break;
case FIND:
// get the employee's name from the file
fileStream >> name;
cout << "Finding " << name << endl;
map<string,Person>::iterator it;
it = m.find(name);
if(it == m.end())
{
cout << "Unable to find " << name << endl;
}
else
cout << it->first;
break;
case DISPLAY_ALL:
displayAll( employees );
break;
default:
cerr << "ERROR: Unknown action " << action << "!" << endl;
exit(1);
}
}

// close the file
fileStream.close();
}


int main( /*int argc, char* argv[] */){

// If just a return (' ') is entered, then use DEFAULT_INPUT_FILENAME.
// Otherwise, read in the input filename from STDIN.
string inputFilename;
cout << "Please enter the input filename (or simply press return to use " << DEFAULT_INPUT_FILENAME << ") ";
getline( cin, inputFilename);
if( inputFilename == ""){
inputFilename = DEFAULT_INPUT_FILENAME;
}

// process transactions in the file
processInputs( inputFilename );
  
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