C++ GCC compiler assignment ----------------------------------------------------
ID: 665235 • Letter: C
Question
C++ GCC compiler assignment
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
****PLEASE READ THIS PART BEFORE CODING!!! THIS IS THE 4TH TIME I'VE ASKED THIS QUESTION WITH THE SAME ANSWER!! I CANNOT USE A SET OF PROGRAMS WRITTEN WITH VISUAL STUDIO, AS IT WILL NOT WORK ON THE STANDARD BAREBONES LINUX GCC COMPILER THAT WE USE. IF I RECEIVE THE SAME ANSWER AGAIN, I WILL CONTACT CHEGG'S CUSTOMER SERVICE. I HAVE LITERALLY GOTTEN THE EXACT SAME ANSWER...WORD FOR WORD, LINE FOR LINE THREE DIFFERENT TIMES! I CANNOT USE A PROGRAM WRITTEN TO RUN IN VISUAL STUDIO!!! THIS MEANS I CAN'T USE STUFF WITH #include "stdafx.h"...IF YOU CANNOT WRITE THIS ON A NON-VISUAL STUDIO GCC COMPILER, PLEASE DO NOT ANSWER THE QUESTION!!! I DO NOT WANT TO WAST ANY MORE QUESTION SLOTS ON THIS QUESTION!!!!!!!!!!! ALSO PLEASE NOTE THAT THIS HAS 7 FILES ASSOCIATED WITH IT, NOT 5.
PLEASE EMAIL YOUR SOLUTIONS TO TADDOBANNION@OUTLOOK.COM BEFORE YOU ANSWER, SO IT IS NOT WASTED AGAIN!!!!****
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
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:
Hourly pay rate (based on Weekly pay, assume a 40-hour work week)
Overtime pay rate (1.5 times hourly rate if over 40 hours)
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 employee’s pay and display her/his pay check on the screen. Be creative!!
Explanation / Answer
Employee.h
#include <string>
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 <iostream>
#include <iomanip>
//----------------------------------------------------------------------------------------------
// 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 << "Employee Name: " << Name" ";
cout << "Employee Social_Security_Number: " << Social_Security_Number << " ";
cout << "Employee Emp_number: " << Emp_number << " ";
benefit.displayBenefits();
cout << "--- Number of Employee Objects Created ---- ";
cout << "Number of employees: " << Employee::getNumEmployees() << " ";
}
//----------------------------------------------------------------------------------------------
// 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 <= annualpay)
{
annualSalary = salary;
}
else if (salary < weeklypay)
{
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 <iostream>
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 Employee ";
cout<<"Category: " << category << " ";
cout<<"Wage: " << showpoint << fixed << wage << " ";
cout<<"Hours: " << showpoint << fixed << hours << " ";
}
double Hourly::getWage()
{
return wage;
}
void Hourly::setWage(double wage)
{
if(wage >= minWage && wage <+ maxWage)
{
this->wage = wage;
}
else if(wage < minWage)
{
this->wage = minWage;
}
else
{
this->wage = maxWage;
}
}
double Hourly::getHours()
{
return hours;
}
void Hourly::setHours(double hours)
{
if (hours > minHours && hours < maxHours)
{
this->hours = hours;
}
else if (hours <= minHours)
{
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 <iostream>
#include <string>
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 << endl;
Benefit hourlyBenefit;
Hourly employee2;
// Call TerminateApplication Proceedure
TerminateApplication();
return 0;
}
void DislayApplicationInformation()
{
// Display Program Header
cout << "Welcome to your Employee Program ";
}
// DisplayDivider Prodedure
void DisplayDivider(string outputTitle)
{
// Display Divider with Output Title
cout << output is ";
}
// DisplayDivider2 Prodedure
void DisplayDivider2(string outputTitle)
{
}
string GetInput (string inputType)
{
string input;
cout<<"Please enter your "<< inputType <<": ";
getline(cin, input);
return input;
}
void TerminateApplication()
{
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.