//********************************************************
//
// Assignment 11 - Object Oriented Design
//
// Name: Jacquelin Saint Lucien
//
// Class: C Fall 2025
//
// Date: 11/29/2025
//
// 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 <iomanip> // std::setprecision, std::setw
#include <iostream> // std::cout, std::fixed
#include <string> // string functions
using namespace std;
// 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
// ----------------------------------------
// Employee Class
// ----------------------------------------
class Employee {
private:
string firstName;
string lastName;
string state;
int clockNum;
double wage;
double hours;
double overtimeHours;
double grossPay;
double stateTax;
double federalTax;
double netPay;
public:
void readInput() {
cout << "Enter Employee First Name: ";
cin >> firstName;
cout << "Enter Employee Last Name: ";
cin >> lastName;
cout << "Enter Employee Tax State: ";
cin >> state;
cout << "Enter Employee Clock Number: ";
cin >> clockNum;
cout << "Enter Employee Hourly Wage Rate: ";
cin >> wage;
cout << "Enter Employee Hours Worked for the Week: ";
cin >> hours;
cout << endl;
}
void calculate() {
// overtime
overtimeHours = (hours > 40) ? hours - 40 : 0;
// gross
grossPay = (hours - overtimeHours) * wage +
overtimeHours * wage * 1.5;
// state tax by state code
if (state == "MA") stateTax = grossPay * 0.05;
else if (state == "NH") stateTax = 0.00;
else if (state == "VT") stateTax = grossPay * 0.06;
else if (state == "NY") stateTax = grossPay * 0.08;
else if (state == "CA") stateTax = grossPay * 0.07;
else stateTax = 0;
// federal tax
federalTax = grossPay * 0.25;
// net pay
netPay = grossPay - stateTax - federalTax;
}
void printResults() const {
cout << " *** Entered Details are ***\n\n";
cout << " First Name: " << firstName << endl;
cout << " Last Name: " << lastName << endl;
cout << " Tax State: " << state << endl;
cout << " Clock Number: " << clockNum << endl;
cout << fixed << setprecision(2);
cout << " Wage Rate: " << wage << endl;
cout << " Hours: " << hours << endl << endl;
cout << " *** Calculated Values are ***\n\n";
cout << " Overtime Hours : " << overtimeHours << endl;
cout << " Gross Pay : $" << grossPay << endl;
cout << " State Tax : $" << stateTax << endl;
cout << " Federal Tax : $" << federalTax << endl;
cout << " Net Pay : $" << netPay << endl << endl;
}
};
// ----------------------------------------
// Main Program
// ----------------------------------------
int main() {
const int SIZE = 5;
Employee emp[SIZE];
for (int i = 0; i < SIZE; i++) {
emp[i].readInput();
emp[i].calculate();
emp[i].printResults();
}
return 0;
}