Hi last week I did an assignmetn that wasn\'t completely right. Can you help me
ID: 3540795 • Letter: H
Question
Hi last week I did an assignmetn that wasn't completely right. Can you help me correct it? I need to correct it so I can o my next assignemnt.
Here is the assignment:
The objective of the lab is to take the UML Class diagram and enhance last week's Employee class by making the following changes:
Due this week:
STEP 1: Understand the UML Diagram
Notice the change in UML diagram. It is common practice to leave out the accessors and mutators (getters and setters) from UML class diagrams, since there can be so many of them. Unless otherwise specified, it is assumed that there is an accessor (getter) and a mutator (setter) for every class attribute.
STEP 2: Create the Project
Create a new project and name it CIS247C_WK5_Lab_LASTNAME. Copy all the source files from the Week 4 project into the Week 5 project.
Before you move on to the next step, build and execute the Week 5 project.
STEP 3: Modify the Employee Class
STEP 4: Create the Salaried Class
STEP 5: Create the Hourly Class
STEP 6: Modify main
Partial Sample output
Partial Sample output
Partial Sample output
This is the program i coded
MAIN.cpp
//
//Employee Program
#include "Employee.h"
#include "Benefit.h"
#include "Salaried.h"
#include "Hourly.h"
//Prototypes
void displayApplicationInformation(void);
void displayDivider(string);
string getInput(string);
string strInput;
void secondEmployee(void);
void thirdEmployee(void);
void terminateMessage(void);
void main()
{
string input= "" ;
int dependents = 0;
double salary = 0;
//
Employee newEmployee;
string dependentsStr;
string vacationStr;
displayApplicationInformation();
displayDivider("Employee 1");
//ask for first name information from user
input = getInput("first name");
newEmployee.setFirstName(input);
//get last name information from user
input = getInput("last name");
newEmployee.setLastName(input);
//get gender information from uuser
input = getInput("gender");
newEmployee.setGender(input);
//get dependents information from user
input = getInput("number of dependents");
dependents = atoi(dependentsStr.c_str());
newEmployee.setDependents(input);
//get salary information from user
input = getInput("salary");
newEmployee.setAnnualSalary(input);
//get health insurance information from user
input = getInput("health insurance");
newEmployee.benefit.setHealthInsurance(input);
//get life insurance information from user
input = getInput("life insurance");
newEmployee.benefit.setLifeInsurance(input);
//get vacation days from user
input = getInput("vacation days");
newEmployee.benefit.setVacation(input);
//display employee Information to screen for first employee (newEmployee)
newEmployee.displayEmployee();
newEmployee.getNumEmployees();
// display the divider for second employee
displayDivider("Employee 2");
setprecision(2) ;
Benefit benefit1("North West Mutual",500000.00,14); //hard code for employee 2
Salaried secondEmployee1(50000.00, 3);
Employee secondEmployee("Jackie", "Chan", 'M', 1, 50000, benefit1);//benefit1 calls all three parameter from Benefit::Benefit
secondEmployee.displayEmployee();
secondEmployee1.displayEmployee();
//display the number of emplyees
newEmployee.getNumEmployees();
//thrid employee
displayDivider("Employee 3");
setprecision(2);
Benefit benefit2("PPO", 100000.00, 20); //hard code for employee3
Employee thirdEmployee("James", "Bond", 'M', 0, 100000.00, benefit2);
Hourly thirdEmployee1("Unknown", 40.00, 50.00);
thirdEmployee.displayEmployee();
thirdEmployee1.displayEmployee();
newEmployee.getNumEmployees();
//display a good bye message
terminateMessage();
}
// this will divide the information by Employee number
void displayDivider(string employeeNum)
{
cout << endl;
cout << "***************" << employeeNum << "****************" << endl;
}
//the getInput function will use the inputType variable as the passdown vairable wich will be replaced by the employee information.
string getInput(string inputType)
{
cout << endl;
string strInput = "";
cout << "Enter " << inputType << " please: ";
cout << setprecision(2)<<fixed; //setting the decimal point to two places
cout << (strInput.c_str()); //strInput is used as the input variable
getline(cin, strInput);
return strInput;
}
//display terminate mssage to user.
void terminateMessage(void)
{
cout << endl;
cout << "Thank you for using this program, GoodBye!"<<endl;
system("pause");
}
Salaried.cpp
//
//Employee Program
#include "Salaried.h"
Salaried::Salaried(void)
{
int MIN_MANAGEMENT_LEVEL= 0;
int MAX_MANAGEMENT_LEVEL= 3;
double const BONUS_PERCENT= .10;
int managementLevel =0;
}
//Salaried::Salaried(/*string fname, string lname, char gen, int dep, */double sal, int manLevel)
//{
//firstName = fname;
//lastName = lname;
//gender = gen;
//dependents = dep;
//annualSalary = sal;
//benefit = benef;
//}
Salaried::Salaried(double sal, int manLevel)
{
managementLevel = manLevel;
}
double Salaried::CalculatePay()
{
BONUS_PERCENT = managementLevel * .10;
return BONUS_PERCENT;
}
void Salaried::displayEmployee()
{
cout << "Salaried Employee" << endl;
cout << "Management Level: " << managementLevel << endl;
}
Salaried.h
//
//Employee Program
#include "Employee.h"
#include "Benefit.h"
#include <string>
#include <iostream>
#include <iomanip>
using namespace std;
class Salaried : public Employee
{
private:
int MIN_MANAGEMENT_LEVEL;
int MAX_MANAGEMENT_LEVEL;
double BONUS_PERCENT;
int managementLevel;
public:
Salaried(void);
Salaried(/*string, string, char, int, /double, /*Benefit, */int);
Salaried(double,int);
double CalculatePay();
void displayEmployee();
};
Hourly.h
//
//Employee Program
#pragma once
#include "Employee.h"
#include <iostream>
#include <iomanip>
#include <string>
class Hourly : public Employee
{
private:
double MIN_WAGE;
double MAX_WAGE;
double MIN_HOURS;
double MAX_HOURS;
double wage;
double hours;
string category;
public:
Hourly();
Hourly(string, double, double);
Hourly (string, string, char, int, double, double, Benefit, string);
double calculatePay();
void displayEmployee();
};
Hourly.cpp
//Employee Program
#include "Hourly.h"
Hourly::Hourly(void)
{
double MIN_WAGE = 10;
double MAX_WAGE = 75;
double MIN_HOURS = 0;
double MAX_HOURS = 50;
double wage = 0;
double hours = 0;
string category = "";
}
Hourly::Hourly(string categ, double wag, double hrs )
{
category = categ;
wage = wag;
hours = hrs;
}
Hourly::Hourly(string fname, string lname, char gen, int dep, double wage, double hours, Benefit benef, string category)
{
}
double Hourly::calculatePay()
{
return wage*hours;
}
void Hourly::displayEmployee()
{
cout << "Hourly Employee" << endl;
cout << "Category: " << category << endl;
cout << "Wage: " << wage << endl;
cout << "Hours: " << hours << endl;
}
Employee.h
//
//Employee Program
#pragma once
#include "iEmployee.h"
#include "Benefit.h"
#include <string>
#include<iostream>
#include <iomanip>
using namespace std;
//employee class
class Employee
{
protected:
string firstName;
string lastName;
char gender;
int dependents;
double annualSalary;
private:
public:
Benefit benefit; //call the benefit class from the Benefit.h file
Employee();
Employee(string, string, char, int, double, Benefit);
double calculatePay ();
void displayEmployee();
string getFirstName();
void setFirstName(string firstName);
string getLastName();
void setLastName(string lastName);
char getGender();
void setGender(char gender);
void setGender(string genderStr);
int getDependents();
void setDependents(int dependents);
void setDependents(string dependentsStr);
double getAnnualSalary();
void setAnnualSalary(double annualSalary);
void setAnnualSalary( string annualSalaryStr);
static int numEmployees;
static int getNumEmployees();
};
Employee.cpp
/
//Employee Program
#include "employee.h"
#include "Salaried.h"
int Employee::numEmployees = 0;
Employee::Employee():benefit()
{
firstName = "not give";
lastName = "not given";
gender = 'U';
dependents = 0;
annualSalary = 20,000;
numEmployees++;
}
Employee::Employee(string param_firstName, string param_lastName, char param_gender, int param_dependents, double param_annualSalary, Benefit benef):benefit(benef)
{
firstName = param_firstName;
lastName = param_lastName;
gender = param_gender;
dependents = param_dependents;
annualSalary = param_annualSalary;
}
void displayApplicationInformation()
{
cout << endl;
cout << "Welcome to the Basic User Interface Program" << endl;
cout << "CIS247, Week 2 Lab" <<endl;
cout << "Name: " << endl;
cout << "This accepts user input as a string, then makes the appropriate data conversion" <<endl;
}
double Employee::calculatePay(void)
{
return annualSalary/52;
}
void Employee::displayEmployee()
{ cout << endl;
cout << "Employee Information" <<endl;
cout << "_______________________________________________" << endl;
cout << endl;
cout << "Name: " << firstName << " " << lastName <<endl;
cout << "Gender: " << gender << endl;
cout << "Dependents: " << dependents << endl;
cout << "Annual Salary: " << setprecision(2)<< fixed<< annualSalary << endl;
cout << "Weekly Salary: " << calculatePay() << endl;
benefit.displayBenefits();
cout << endl;
}
string Employee::getFirstName()
{
return firstName;
}
void Employee::setFirstName(string newFirstName)
{
firstName = newFirstName;
}
string Employee::getLastName()
{
return lastName;
}
void Employee::setLastName(string newLastName)
{
lastName = newLastName;
}
char Employee::getGender()
{
return gender;
}
void Employee::setGender(char newGender)
{
gender = newGender;
}
void Employee::setGender(string genderStr)
{
gender = genderStr.at(0);
}
int Employee::getDependents()
{
return dependents;
}
void Employee::setDependents(int newDependents)
{
dependents = newDependents;
}
void Employee::setDependents(string dependentsStr)
{
dependents =atoi(dependentsStr.c_str());
}
double Employee::getAnnualSalary()
{
return annualSalary;
}
void Employee::setAnnualSalary(double newAnnualSalary)
{
annualSalary = calculatePay() * 50;
}
void Employee::setAnnualSalary(string salary)
{
annualSalary = atof(salary.c_str());
}
int Employee::getNumEmployees()
{
cout << "---- Number of Employee Object Created----" << endl;
cout << "Number of employees: " << numEmployees<< endl;
return 0;
}
Benefit.cpp
//
//Employee Program
#include "Benefit.h"
#include "Employee.h"
//initialize variable in default constructor
Benefit::Benefit()
{
string healthInsurance = "not given";
double lifeInsurance = 0.00;
int vacation = 0;
}//set bypass variable to different
Benefit::Benefit(string health, double life, int vaca)
{
healthInsurance = health;
lifeInsurance = life;
vacation = vaca;
}
// this functions displays information gathered by user into screen
void Benefit::displayBenefits()
{
cout << endl;
cout << "Benefit Information" <<endl;
cout << "_______________________________________________" << endl;
cout << "Health Insurance: " << healthInsurance <<endl; ;
cout << "Life Insurance: " << lifeInsurance<< endl;
cout << "Vacation Days: " << vacation << " days"<< endl;
}
//this function returns healthInsurance value
string Benefit::getHealthInsurance()
{
return healthInsurance;
}
// this functions sets it as a string
void Benefit::setHealthInsurance(string hins)
{
healthInsurance = hins;
}
//returns lifeInsruance value
double Benefit::getLifeInsurance()
{
return lifeInsurance;
}
//sets string variable
void Benefit::setLifeInsurance(double lifeIns)
{
lifeInsurance = lifeIns;
}
//convertion frm double to string
void Benefit::setLifeInsurance(string lIns)
{
lifeInsurance = atof(lIns.c_str());
}
//returns vacation value
int Benefit::getVacation()
{
return vacation;
}
// sets string variable for vacation
void Benefit::setVacation(int vaca)
{
vacation = vaca;
}
//converts vacation value to string
void Benefit::setVacation(string vacStr)
{
vacation = atoi(vacStr.c_str());
}
Benefit.h
//
//Employee Program
#pragma once
#include <string>
#include <iostream>
#include <iomanip>
using namespace std;
//new class Benefit
class Benefit
{
private: //prvate attributes
string healthInsurance;
double lifeInsurance;
int vacation;
public:
Benefit();
Benefit(string, double, int);
void displayBenefits();
string getHealthInsurance();
void setHealthInsurance(string hins);
double getLifeInsurance();
void setLifeInsurance(double lifeIns);
void setLifeInsurance(string);
int getVacation();
void setVacation(int vaca);
void setVacation(string vacStr);
};
The objective of the lab is to take the UML Class diagram and enhance last week's Employee class by making the following changes: Create a class called Salaried that is derived from Employee. Create a class called Hourly that is also derived from Employee. Override the base class calculatePay() method. Override the displayEmployee() method. Due this week: Capture the Console output window and paste into a Word document. Zip the project folder file. Put the zip file and screenshots (Word document) in the Dropbox. Notice the change in UML diagram. It is common practice to leave out the accessors and mutators (getters and setters) from UML class diagrams, since there can be so many of them. Unless otherwise specified, it is assumed that there is an accessor (getter) and a mutator (setter) for every class attribute. Create a new project and name it CIS247C_WK5_Lab_LASTNAME. Copy all the source files from the Week 4 project into the Week 5 project. Before you move on to the next step, build and execute the Week 5 project. Using the updated Employee class diagram, modify the attributes to be protected. Delete the iEmployee interface class, and remove the reference from the Employee class. Using the UML Diagrams from Step 1, create the Salaried classes, ensuring to specify that the Salary class inherits from the Employee class. For each of the constructors listed in the Salaried class, ensure to invoke the appropriate base class constructor and pass the correct arguments to the base class constructor. This will initialize the protected attributes and update the numEmployees counter. The valid management levels are 0, 1, 2, and 3, and should be implemented as a constant. Override the calculatePay method to add a 10 percent bonus for each of the management levels (i.e., bonus percentage = managementLevel * .10). The bonus percentage should be implemented as a constant. Override the displayEmployee() method to add the management level to the employee information. Using the UML Diagrams from Step 1, create the Hourly classes, ensuring to specify that the Hourly class inherits from the Employee class. For each of the constructors listed in the Hourly class, ensure to invoke the appropriate base class constructor and pass the correct arguments to the base class constructor. This will initialize the protected attributes and update the numEmployees counter. The valid category types are "temporary", "part time", and "full time". The provided hours must be more than 0 hours and less than 50 hours, and the limits should be implemented as constants. The provided wage must be between 10 and 75, and the limits should be implemented as constants. Override the calculatePay method by multiplying the wages by the number of hours. Override the Employee setAnnualSalary method and set the annual salary by multiplying the weekly pay by 50. Override the displayEmployee() method to add the category to the hourly employee information. Using previous weeks' assignments as an example, create at least one Employee, Hourly, and Salaried employee. For each object created, display the number of employees created. For each object created, write statements to exercise each of the public methods listed in the Class diagram. For each object created, invoke the object's displayEmployee() method to display the employee's information. For employee, the following information needs to be displayed: For salaried employee, the following information needs to be displayed: For hourly employee, the following information needs to be displayed:
Explanation / Answer
Helllo I can help u in any assignment regariding c++ ... contact me on alwaysaturservice@hotmail.com
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.