// Project 2 : Employee Database Part 2 // Programmer : Sean Smith // Class : CSC215 // Professor : Phill Miller #include #include using namespace std; // Initializing Employee Class class Employee { public: // Declaring Variables string employeeName; string employeeJobTitle; double employeeWage; double employeeHours; // Creating Employee Name Function string GetEmployeeName() { return employeeName; } // Creating Employee Job Title Function string GetEmployeeJobTitle() { return employeeJobTitle; } // Creating Employee Wage Function double GetEmployeeWage() { return employeeWage; } // Creating Employee Hours Function double GetEmployeeHours() { return employeeHours; } }; // Calculating Employee Pay double GetEmployeePay(double hours, double wage) { // Returning Employee Pay return (hours*wage); } // Initializing isHighlyPaid Function bool isHighlyPaid(Employee employeeObject) { // Determining if the Employee is Highly Paid if (employeeObject.GetEmployeeWage() >= 20) { return true; } else if (GetEmployeePay(employeeObject.GetEmployeeHours(), employeeObject.GetEmployeeWage()) >= 800) { return true; } else { return false; } } // Initializing GetEmployee Function Employee GetEmployee() { // Create the Employee object. Employee employeeObject; // Declaring Variables string tempName; string tempJobTitle; // Getting Employee Name cout << "Enter Name : "; do { cin >> tempName; employeeObject.employeeName.append(tempName.insert(0, " ")); } while(cin.peek() == ' '); // Aquiring Employee Job Title cout << "Enter Job Title : "; do { cin >> tempJobTitle; employeeObject.employeeJobTitle.append(tempJobTitle.insert(0, " ")); } while(cin.peek() == ' '); // Aquiring Employee Hourly Wage cout << "Enter Hourly Wage : "; cin >> employeeObject.employeeWage; // Aquiring Employee Hours cout << "Enter Hours Worked : "; cin >> employeeObject.employeeHours; // Returning Employee Object return employeeObject; } // Initializing Employee List Function void DisplayEmployees(Employee employeeArray[]) { int increment; for (increment = 0; increment < 10; increment++) { // Output Employee Information and Pay cout << "-------------[Employee #" << increment+1 << "]-------------" << endl; cout << "Employee Name : " << employeeArray[increment].GetEmployeeName(); // Putting '*' Next to Highly Paid Employees if (isHighlyPaid(employeeArray[increment])) { cout << "*" ; } cout << endl; cout << "Employee Job Title : " << employeeArray[increment].GetEmployeeJobTitle() << endl; cout << "Employee Pay : " << GetEmployeePay(employeeArray[increment].GetEmployeeHours(), employeeArray[increment].GetEmployeeWage()) << endl; } } // Declaring employeeObjectArray Employee employeeObjectsArray[10]; int main() { // Outputing Header cout << "============+--------------------------------+============" << endl; cout << "============| Employee Database |============" << endl; cout << "============| Programmer : Sean Smith |============" << endl; cout << "============| Class : CSC215 |============" << endl; cout << "============| Professor : Pill Miller |============" << endl; cout << "============+--------------------------------+============\n" << endl; cout << "<><><><><><><><><><><><><><><><><><><><><><><><><><><><><>" << endl; cout << "><><><><><><[ Employee Info ]><><><><><><" << endl; cout << "<><><><><><><><><><><><><><><><><><><><><><><><><><><><><>\n" << endl; int increment; for (increment = 0; increment < 10; increment++) { // Calling GetEmployee for Each Employee cout << "-------------[Employee #" << increment+1 << "]-------------" << endl; employeeObjectsArray[increment] = GetEmployee(); } cout << "\n<><><><><><><><><><><><><><><><><><><><><><><><><><><><><>" << endl; cout << "><><><><><><[ Employee Pay ]><><><><><><" << endl; cout << "<><><><><><><><><><><><><><><><><><><><><><><><><><><><><>\n" << endl; // Calling DisplayEmployees Function DisplayEmployees(employeeObjectsArray); cout << "\n<><><><><><><><><><><><><><><><><><><><><><><><><><><><><>" << endl; cout << "><><><><><><[ Fin ]><><><><><><" << endl; cout << "<><><><><><><><><><><><><><><><><><><><><><><><><><><><><>\n" << endl; return 0; }