Question
C++ CLASS AND INHERITANCE ASSIGNMENT. ***PLEASE READ BELOW BEFORE CODING THIS!!! IT'S BEEN DONE TWICE ALREADY AND IT WILL NOT WORK FOR ME!!! I AM
C++ CLASS AND INHERITANCE ASSIGNMENT.
***PLEASE READ BELOW BEFORE CODING THIS!!! IT'S BEEN DONE TWICE ALREADY AND IT WILL NOT WORK FOR ME!!! I AM NOT USING VISUAL STUDIO TO COMPILE!!! WE USE GCC COMPILER IN LINUX TERMINAL ON CENTOS!!! I WILL POST WHAT HAS BEEN DONE AND DIDN'T WORK AFTER THE ASSIGNMENT.***
**NOTE**
WE DO NOT use Visual Studio in the class I am taking. We are using a GCC compiler in Linux. I realize that Visual Studio is superior and all, but that is not the way the class is being taught. I don't mind editing a few things out, but please keep in mind I have to make this work on a Linux GCC compiler.
Thanks
This project is an exercise in classes and inheritance. It should be implemented using multiple (specification, implementation, and application) source code files.
Note: All data members should be private.
The goal of the program is to print pay checks for a company.
To accomplish this task, you will need to create and derive several classes.
1. file names: Employee.h, Employee.cpp Design a base class named Employee. The class should keep the following information in its data members:
Employee name
Social Security Number, in the format xxx-xx-xxxx, where x is a digit within the range 0 through 9
Employee number, in the format xxx-L, where x is a digit within the range 0 through 9, and the L is a letter within the range A through M. Add a constructor and other appropriate member functions to manipulate the class data members.
Input Validation: Only accept valid Social Security Numbers (with no alphabetic characters) and valid Employee Numbers (as described above). Note: Input validation should be done in the setter functions and no input statements should be used.
2. file names: EmployeePay.h, EmployeePay.cpp Design a class named EmployeePay. This class should be derived from the Employee class. It should store the following information in data members:
Annual pay
Weekly pay (To be calculated from Annual Pay) Add a constructor and other appropriate member functions to manipulate the class data members. Input Validation: Do not accept negative values for annual pay.
3. file names: HourlyPay.h, HourlyPay.cpp Design a class called HourlyPay. This class should be derived from the EmployeePay class. It should store the following information in data members:
Overtime pay rate (1.5 times hourly rate if over 40 hours) Hourly pay rate (based on Weekly pay, assume a 40-hour work week)
Number of hours worked Add a constructor and other appropriate member functions to manipulate the class data members. Input Validation: Do not accept values over 60 for hours worked.
4. file name: EmployeeMain.cpp Finally, using the classes you have created, write a program which uses a function with the following prototype to print a pay check: void PrintCheck(HourlyPay); The program should ask for sample data for the employee information and then calculate the employees pay and display her/his pay check on the screen.
Be creative!!
Again, I cannot use a VS written program...you know, with the scope resolution differences and so on and so forth. I can make some of the modifications, but I have run short on time to finish this, so I need it to be pretty much ready to go.
Thanks
*PS*
I asked this question earlier today and got a set of classes and implementations that I assume were done with VS (as that really is the standard). I need this to work on a Linux GCC compiler!!!
***HERE IS WHAT DIDN'T WORK EARLIER...PLEASE, CODE THIS IN CODEBLOCKS OR SOMETHING BESIDES VISUAL STUDIO!!!!***
Employee.h
#include using namespace std;
class Employee { protected: string Name; int Social_Security_Number int Emp_number;
private: // Declare Data Members static int numEmployees;
public: // Constructors and Destructor Employee(void); Employee(string,int,int); ~Employee(void);
// Methods to Access Attributes double calculatePay(); void displayEmployee();
// Getters and Setters string Employee::getName(); void Employee::setName(string); int Employee::getSocial_Security_Number(); void Employee::setSocial_Security_Number(int); int Employee::getEmp_number(); void Employee::setEmp_number(int); };
employee.cpp
#include \"stdafx.h\" #include \"Employee.h\" #include #include //---------------------------------------------------------------------------------------------- // Declare Variables const double weeklypay = 50000; const double annualpay = 250000; int Employee::numEmployees = 0; //---------------------------------------------------------------------------------------------- // Default Employee Constructor Employee::Employee() : Name(\"not given\"), Social_Security_Number(0), Emp_number(0), { numEmployees++; } //---------------------------------------------------------------------------------------------- // Multi-Arg Employee Constructor Employee::Employee(string first, int ssn, int emp) :
Name(first), Social_Security_Number(ssn), Emp_number(emp), numEmployees++; } //---------------------------------------------------------------------------------------------- // Employee Deconstructor Employee::~Employee() { numEmployees--; } //---------------------------------------------------------------------------------------------- // Define CalculatePay Function double Employee::calculatePay() { return (annualSalary/numberOfWeeks); } //---------------------------------------------------------------------------------------------- // DisplayEmployee Function void Employee::displayEmployee() { cout cout cout benefit.displayBenefits(); cout cout } //---------------------------------------------------------------------------------------------- // Define GetName and SetName string Employee::getName() { return Name; } void Employee::setName(string name) { Name = name; }
int Employee::getSocial_Security_Number() { return Social_Security_Number; }
void Employee::setSocial_Security_Number(int ssn) { Social_Security_Number = ssn; }
int Employee::getEmp_number() { return Emp_number; }
void Employee::setEmp_number(int emp) { Emp_number = emp; }
// Define GetAnnualSalary and both SetAnnualSalary (overloaded) double Employee::getAnnualSalary() { return annualSalary; } void Employee::setAnnualSalary(double salary) { if (salary >= weeklypay && salary => { annualSalary = salary; } else if (salary { annualSalary = weeklypay; } else { annualSalary = annualpay; } }
void Employee::setAnnualSalary(string sal) { Employee::setAnnualSalary( atof(sal.c_str())); }
// Define GetNumEmployees int Employee::getNumEmployees() { return Employee::numEmployees;
}
Hourly.h
#include \"employee.h\" class Hourly : public Employee { public: Hourly(void); ~Hourly(void); private: double minWage; double maxWage; double minHours; double maxHours; double wage; double hours; string category; public: Hourly(double wage, double hours, string category); Hourly(string Name, int Social_Security_Number, int Emp_number); double calculatePay(void); void displayEmployee(void); double Hourly::getWage(); void Hourly::setWage(double); double Hourly::getHours(); void Hourly::setHours(double); string Hourly::getCategory(); void Hourly::setCategory(string); void Hourly::setAnnualSalary(double); };
Hourly.cpp #include \"Hourly.h\" #include
using namespace std;
Hourly::Hourly(void) { const double minWage = 10.0; const double maxWage = 75.0; const double minHours = 0.0; const double maxHours = 50.0; wage = 0.0; hours = 0.0; }
Hourly::~Hourly(void) { }
Hourly::Hourly(double wage, double hours, string category) { }
Hourly::Hourly(string Name, int Social_Security_Number, int Emp_Number) { }
double Hourly::calculatePay(void) { return (wage * hours); }
void Hourly::displayEmployee(void) { Hourly::setAnnualSalary(annualSalary); Employee::displayEmployee(); cout\"hourly> cout\"category:\\t\\t\"> cout\"wage:\\t\\t\\t\"> cout\"hours:\\t\\t\\t\"> }
double Hourly::getWage() { return wage; } void Hourly::setWage(double wage) { if(wage >= minWage && wage +> { this->wage = wage; } else if(wage { this->wage = minWage; } else { this->wage = maxWage; } } double Hourly::getHours() { return hours; } void Hourly::setHours(double hours) { if (hours > minHours && hours { this->hours = hours; } else if (hours => { this->hours = minHours; } else { this->hours = maxHours; } }
string Hourly::getCategory() { return category; } void Hourly::setCategory(string category) { if (category.compare(\"temporary\")==0) { this->category = category; } else if (category.compare(\"part time\")==0) { this->category = category; } else if (category.compare(\"full time\")==0) { this->category = category; } else { this->category = \"Unknown\"; } }
void Hourly::setAnnualSalary(double salary) { salary = calculatePay() * 50; this->annualSalary = salary; } Main #include \"Employee.h\" #include \"Hourly.h\" #include #include using namespace std; //---------------------------------------------------------------------------------------------- // Main Function int main() { DislayApplicationInformation(); DisplayDivider(\"Employee 1\"); Employee employee1; employee1.setFirstName(GetInput(\"\\Name\")); employee1.setDependents(GetInput(\"Social_Security_Number\")); employee1.setAnnualSalary(GetInput(\"Employee number\")); employee1.setBenefit(benefit); DisplayDivider2(\"Employee Information\"); employee1.displayEmployee(); //Display Employee1 Data cout Benefit hourlyBenefit; Hourly employee2; // Call TerminateApplication Proceedure TerminateApplication(); return 0; } void DislayApplicationInformation() { // Display Program Header cout } // DisplayDivider Prodedure void DisplayDivider(string outputTitle) { // Display Divider with Output Title cout }
// DisplayDivider2 Prodedure void DisplayDivider2(string outputTitle) { } string GetInput (string inputType) { string input; cout\"please>\":> getline(cin, input); return input; } void TerminateApplication() { }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started