need help with current code, I am a newbie. keep in mind, that everything that can be, needs to be passed by value. and only three functions can be called from main. they are getEmployeeData, displayEmployeeInfo, and calculateGrossPay. and all functiontions must keep the header type below. Help is greatly appreciated.
#include <iostream>
using namespace std;
#include <cstdlib>
#include <string>
bool getEmployeeData (int, char, char, int&, int&, int&, int);
float calculateGrossPay (int, char, int&, int&, int&, int);
void displayEmployeeInfo(int, char, int);
bool tryAgain(char, char);
bool isValidStatus(char, char);
int main()
{
int ID, Salary, hourwrk, sales, grossPay;
char pyrllSt = ' ';
char quit;
bool result = true;
while (result)
{
result = getEmployeeData (ID, pyrllSt, quit, Salary, hourwrk, sales, grossPay);
if (result)
{
displayEmployeeInfo (ID, pyrllSt, grossPay);
}
else
{
calculateGrossPay(ID, pyrllSt, Salary, hourwrk, sales, grossPay);
}
}
return (1);
}
bool getEmployeeData (int ID, char pyrllSt, char quit, int Salary, int hourwrk, int sales, int grossPay)
{
cout << "Enter employee ID: " << endl;
cin >> ID;
if (ID > 0)
{
cout << "Enter payroll status: " << endl;
cin >> pyrllSt;
if (isValidStatus(pyrllSt, quit))
{
if (pyrllSt == 's' || pyrllSt == 'S')
{
cout << "Enter monthly salary: " << endl;
}
if (pyrllSt == 'h' || pyrllSt == 'H')
{
cout << "Enter number of hours worked this month: " << endl;
}
if (pyrllSt == 'c' || pyrllSt == 'C')
{
cout << "Enter total sales for this month: " << endl;
}
}//if isValid Status
return true;
}
else
{
return false;
}
}
bool isValidStatus (char pyrllSt, char quit)
{
bool isGood = true;
cout << "Enter payroll status: " << endl;
cin >> pyrllSt;
while (isGood)
{
isGood = (pyrllSt == 's' || pyrllSt == 'S' || pyrllSt == 'h' || pyrllSt == 'H' || pyrllSt == 'c' || pyrllSt =='C');
if (isGood)
{
return true;
}
else
{
return tryAgain(pyrllSt, quit);
}
}
}
bool tryAgain(char pyrllSt, char quit)
{
bool (toQuit) = true;
cout << "Type Q or q to quit, any other key to continue: " << endl;
cin >> quit;
while (toQuit)
{
toQuit = (quit == 'q' || quit == 'Q');
if (toQuit)
{
cout << "*** Program Terminated ***" << endl;
return false;
}
}
while(!toQuit)
{
cout << "Re-enter: 's' or 'S' for salaried, 'h' or 'H' for hourly, " << endl;
cout << "'c' or 'C' for commissioned." << endl;
cin >> pyrllSt;
if (pyrllSt == 's' || pyrllSt == 'S' || pyrllSt == 'h' || pyrllSt == 'H' || pyrllSt == 'c' || pyrllSt =='C')
{
return true;
}
}
float calculateGrossPay (int ID, char pyrllSt, int Salary, int hourwrk, int sales, int grossPay)
{
if (pyrllSt == 's' || pyrllSt == 'S')
{
grossPay = Salary;
displayEmployeeInfo(ID, pyrllSt, grossPay);
return grossPay;
}
else if (pyrllSt == 'h' || pyrllSt == 'H')
{
grossPay = hourwrk * 18.75;
displayEmployeeInfo(ID, pyrllSt, grossPay);
return grossPay;
}
else if (pyrllSt == 'c' || pyrllSt == 'C')
{
grossPay = sales * .06 + 1000.00;
displayEmployeeInfo(ID, pyrllSt, grossPay);
return grossPay;
}
}
void displayEmployeeInfo (int ID, char pyrllSt, int grossPay)
{
cout << "Employee ID: " << ID << endl;
cout << "Payroll Status: " << pyrllSt << endl;
cout << "Gross Pay: " << grossPay << endl;
}