Question: / / * * * * * * * * * * * * * * * * * * * * * * *

//********************************************************
//
// Assignment 11- Object Oriented Design
//
// Name:
//
// Class: C Programming,
//
// Date:
//
// Description: An object oriented program design using
// C++ that will process our existing set of employees.
// It utilizes a class called Employee and generates an
// array of objects that are used to store, calculate,
// and print out a simple report of inputted and calculated
// values.
//
//
// Object Oriented Design (using C++)
//
//********************************************************
#include // std::setprecision, std::setw
#include // std::cout, std::fixed
#include // string functions
// define constants
#define EMP_SIZE 5
#define STD_HOURS 40.0
#define OT_RATE 1.5
#define MA_TAX_RATE 0.05
#define NH_TAX_RATE 0.0
#define VT_TAX_RATE 0.06
#define CA_TAX_RATE 0.07
#define DEFAULT_TAX_RATE 0.08
#define NAME_SIZE 20
#define TAX_STATE_SIZE 3
#define FED_TAX_RATE 0.25
#define FIRST_NAME_SIZE 10
#define LAST_NAME_SIZE 10
using namespace std;
// class Employee
class Employee
{
private:
// private data available only to member functions
string firstName; // Employee First Name
string lastName; // Employee Last Name
string taxState; // Employee Tax State
int clockNumber; // Employee Clock Number
float wageRate; // Hourly Wage Rate
float hours; // Hours worked in a week
float overTimeHrs; // Overtime Hours worked
float grossPay; // Weekly Gross Pay
float stateTax; // State Tax
float fedTax; // Fed Tax
float netPay; // Net Pay
// private member function to calculate Overtime Hours
float calcOverTimeHrs ()
{
// Calculate the overtime hours for the week
if (hours > STD_HOURS)
overTimeHrs = hours - STD_HOURS; // ot hours
else
overTimeHrs =0; // no ot hours
// the calculated overtime hours
return (overTimeHrs);
}// calcOverTimeHrs
// private member function to calculate Gross Pay
float calcGrossPay ()
{
// Process gross pay based on if there is overtime
if (overTimeHrs >0)
{
// overtime
grossPay =(STD_HOURS * wageRate)// normal pay
+(overTimeHrs *(wageRate * OT_RATE)); // ot pay
}
else // no overtime pay
{
grossPay = wageRate * hours; // normal pay
}
// the calculated gross pay
return (grossPay);
}// calcGrossPay
// private member function to calculate State Tax
float calcStateTax ()
{
float theStateTax; // calculated state tax
theStateTax = grossPay; // initialize to gross pay
// calculate state tax based on where employee resides
if (taxState.compare("MA")==0)
theStateTax *= MA_TAX_RATE;
else if (taxState.compare("VT")==0)
theStateTax *= VT_TAX_RATE;
else if (taxState.compare("NH")==0)
theStateTax *= NH_TAX_RATE;
else if (taxState.compare("CA")==0)
theStateTax *= CA_TAX_RATE;
else
theStateTax *= DEFAULT_TAX_RATE; // any other state
// return the calculated state tax
return (theStateTax);
}// calcStateTax
// private member function to calculate Federal Tax
float calcFedTax ()
{
float theFedTax; // The calculated Federal Tax
// Federal Tax is the same for all regardless of state
theFedTax = grossPay * FED_TAX_RATE;
// return the calculated federal tax
return (theFedTax);
}// calcFedTax
// private member function to calculate Net Pay
float calcNetPay ()
{
float theNetPay; // total take home pay (minus taxes)
float theTotalTaxes; // total taxes owed
// calculate the total taxes owed
theTotalTaxes = stateTax + fedTax;
// calculate the net pay
theNetPay = grossPay - theTotalTaxes;
// return the calculated net pay
return (theNetPay);
}// calcNetPay
public:
/p/ lic member functions that can be called
// to access private data member items

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!