I think that the only function that needs fixing is my ComputeHourlyPay function. Could somebody take a look and help me out here.
//Name: Nick Auffarth
//Class: CS 140 Section 003
//Assignment: p03
//Date: October 15, 2007
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
using namespace std;
const char OFFICE = 'A';
const char MANUFACTURING = 'B';
const char QUIT = 'Q';
const int WAGON_LINE = 1;
const int SLED_LINE = 2;
const int ROLLER_SKATE_LINE = 3;
const double OVERTIME_SCALE = 1.5;
const double WAGON_BONUS = 1.10;
const double SLED_BONUS = 1.25;
const double ROLLER_SKATE_BONUS = 1.5;
void ProgrammerNote();
char ChooseDepartmentMenu();
void ProcessOfficeWorker();
double ComputeHourlyPay(double hoursWorked, double hourlyRate);
void DisplayPay(string empName, double regularPay, double overtimePay, double bonusPay, double totalPay);
void ProcessManufacturingWorker();
int ChooseProductionLineMenu();
void main()
{
ProgrammerNote();
char choice;
do
{
choice = ChooseDepartmentMenu();
switch(choice)
{
case 'a':
case 'A':
{
ProcessOfficeWorker();
}break;
case 'b':
case 'B':
{
ProcessManufacturingWorker();
}
break;
case 'q':
case 'Q':
{
}
break;
}
}
while(choice != 'q' && choice != 'Q');
}
void ProgrammerNote()
{
cout << "Programmed by Nick Auffarth" << endl << endl;
}
char ChooseDepartmentMenu()
{
char choice;
cout << setw(5) << " " <<"-------------------"<< endl;
cout << setw(6) << " " <<"Department Menu" << endl;
cout << setw(5) << " " <<"-------------------"<< endl;
cout << setw(5) << " " <<"[A] Office" << endl;
cout << setw(5) << " " <<"[B] Manufacturing" << endl;
cout << setw(5) << " " <<"[Q] Quit" << endl << endl;
do
{
cout << setw(5) << " " <<"Enter Your Selection [A|B|Q]: ";
cin >> choice;
cout << endl << endl;
if(choice != 'a' && choice != 'A' && choice != 'b' && choice != 'B' && choice != 'q' && choice != 'Q')
{
cerr << setw(5) << " " << "Error: Invalid Choice. Please Try Again." << endl << endl;
}
}while (choice != 'a' && choice != 'A' && choice != 'b' && choice != 'B' && choice != 'q' && choice != 'Q');
return (choice);
}
double ComputeHourlyPay(double hoursWorked, double hourlyRate)
{
double regularPay = 0;
double overtimePay;
double totalPay;
cout << fixed
<< setprecision(2);
if(hoursWorked <= 40)
{
regularPay = ComputeHourlyPay(hoursWorked, hourlyRate);
}
if(hoursWorked > 40)
{
overtimePay = ComputeHourlyPay(hoursWorked - 40, hourlyRate * OVERTIME_SCALE);
}
totalPay = regularPay + overtimePay;
return (totalPay);
}
void DisplayPay(string empName, double regularPay, double overtimePay, double bonusPay, double totalPay)
{
cout << fixed
<< setprecision(2);
cout << "Employee Name" << setw(5) << ":" << empName << endl;
cout << "Regular" << setw(13) << ": $" << regularPay << endl;
cout << "Overtime" << setw(12) << ": $" << overtimePay << endl;
cout << "Bonus" << setw(15) << ": $" << bonusPay << endl;
cout << "Total" << setw(15) << ": $" << totalPay << endl;
}
void ProcessOfficeWorker()
{
string empName;
double hoursWorked;
double hourlyRate;
double regularPay = 0;
double overtimePay = 0;
double bonusPay = 0;
double totalPay = 0;
cout << "Enter employee's last name: ";
cin >> empName;
cout << "Enter hours worked: ";
cin >> hoursWorked;
cout << "Enter hourly rate: ";
cin >> hourlyRate;
cout << endl << endl;
ComputeHourlyPay(hoursWorked, hourlyRate);
DisplayPay(empName, regularPay, overtimePay, 0, totalPay);
}
void ProcessManufacturingWorker()
{
string empName;
double hoursWorked;
double hourlyRate;
double regularPay = 0;
double overtimePay = 0;
double bonusPay = 0;
double totalPay = 0;
cout << "Enter employee's last name: ";
cin >> empName;
cout << "Enter hours worked: ";
cin >> hoursWorked;
cout << "Enter hourly rate: ";
cin >> hourlyRate;
ComputeHourlyPay(hoursWorked, hourlyRate);
ChooseProductionLineMenu();
DisplayPay(empName, regularPay, overtimePay, bonusPay, totalPay);
}
int ChooseProductionLineMenu()
{
int ans;
double numItems;
double bonusPay;
cout << endl;
cout << setw(5) << " " <<"-------------------"<< endl;
cout << setw(6) << " " <<"Manufacturing Menu" << endl;
cout << setw(5) << " " <<"-------------------"<< endl;
cout << setw(5) << " " <<"[1] Wagons" << endl;
cout << setw(5) << " " <<"[2] Sleds" << endl;
cout << setw(5) << " " <<"[3] Roller Skates" << endl << endl;
do
{
cout << setw(5) << " " <<"Enter Your Selection [1-3]: ";
cin >> ans;
if(ans != 1 && ans != 2 && ans != 3)
{
cerr << setw(5) << " " << "Error: Invalid Choice. Please try again." << endl << endl;
}
}while(ans != 1 && ans != 2 && ans != 3);
cout << endl << endl;
cout << "How many items were made? ";
cin >> numItems;
cout << endl;
switch(ans)
{
case 1:
{
bonusPay = numItems * WAGON_BONUS;
}break;
case 2:
{
bonusPay = numItems * SLED_BONUS;
}break;
case 3:
{
bonusPay = numItems * ROLLER_SKATE_BONUS;
}break;
}
return (ans);
}