Hello,
I am getting strange values in my display for the salary, hourly or commission.
I do have to use arrays and wondering if there is a simple fix. Maybe I need a pointer to the array? If anyone has a suggestion, please let me know.
Thank you.

#include <iostream> 
#include <iomanip>
using namespace std;
#include <string>
int getEmployeeData (string[], char[], const int, double[]);
void displayEmployeeInfo (string[], char[], int, double[], double[]);
bool isValidStatus(char);
bool tryAgain();
bool isValidID (string);
float calculateGrossPay(char[], double[], int, double[]);

int main()
{
    const int numEmp = 4;
    string ID[numEmp];
    double Money[numEmp];
    double totalPayroll[numEmp];
    char pyrllSt[numEmp];
    double grossPay[numEmp];
    getEmployeeData(ID, pyrllSt, numEmp, Money);
    displayEmployeeInfo(ID, pyrllSt, numEmp, grossPay, totalPayroll);

    return 0;   
}


int getEmployeeData (string ID[], char pyrllSt[], const int numEmp, double Money[])
{
        for (int index = 0; index < numEmp; index++)
        {
            do
            {
                cout << "Enter employee ID:" << index +1 << endl;
                cin >> ID[index];
            } while(!isValidID(ID[index])); 
            do
            {
                cout << "Enter payroll status:" << endl;
                cin >> pyrllSt[index];
            }while (!isValidStatus(pyrllSt[index]));

            if (pyrllSt[index] == 's' || pyrllSt[index] == 'S')
            {
                cout << "Enter the monthly salary:" << endl;
            }

            else if (pyrllSt[index] == 'h' || pyrllSt[index] == 'H')
            {
                cout << "Enter the number of hours worked this month:" << endl;
            }

            else if (pyrllSt[index] == 'c' || pyrllSt[index] == 'C')
            {
                cout << "Enter total sales for this month: " << endl;
            }
            cin >> Money[index];
        }
        return Money[index];
}                           
bool isValidStatus(char pyrllSt)
{
    if (pyrllSt == 's' || pyrllSt == 'S' || pyrllSt == 'h' || pyrllSt == 'H' || pyrllSt == 'c' || pyrllSt == 'C')
    {
        return true;
    }
    else 
    {
        tryAgain();
        cout << "Re-enter 's' or 'S' for salaried, 'h' or 'H' for hourly," << endl;
        cout << "'c' or 'C' for commissioned." << endl;
        return false;
    }
}

bool tryAgain()
{
    char quit;

    cout << "Do you want to try again or quit?" << endl;
    cout << "Type Q or q to quit, any other key to continue: " << endl;
    cin.get(quit);

    if (quit != '\n')
    {
        cin.ignore();
    }

    cin.get(quit);

    if (quit == 'q' || quit == 'Q')
    {
        return false;
    }

    else
    {
        return true;
    }
}


void displayEmployeeInfo (string ID[], char pyrllSt[], const int numEmp, double grossPay[], double totalPayroll[])
{
    for (int index = 0; index < numEmp; index++)
    {
    cout << ID[index] << endl;
    cout << pyrllSt[index] << endl;
    cout << grossPay[index] << endl;
    }
    cout << totalPayroll[index];
}

bool isValidID(string ID)
{
    for (int index = 0; index < ID.length(); index++)
    {   
        if(ID[0] < 48 || ID[0] > 57)
        {
            cout << "*** INVALID PAYROLL ID ***" << endl;
            return false;
        }
    }   
    if(ID.length() != 3)
    {
        cout << "*** INVALID PAYROLL ID ***" << endl;
        return false;
    }
    else
    {
        return true;
    }
}

float calculateGrossPay (char pyrllSt[], double grossPay[] , const int numEmp, double Money[])
{
    for (int index = 0; index < numEmp; index++)
    {
        if (pyrllSt[index] == 's' || pyrllSt[index] == 'S')
        {
            grossPay[index] = Money[index];
        }
        if (pyrllSt[index] == 'h' || pyrllSt[index] == 'H')
        {
            grossPay[index] = Money[index] * 18.75;
        }
        if (pyrllSt[index] == 'c' || pyrllSt[index] == 'C')
        {
            grossPay[index] = (Money[index] * 0.06) + 1000.00;
        }
    }
    return grossPay[index];
}

Strange values typically mean that you've forgotten to initialize a variable. This is the bug you should be searching for using print statements and a debugger if you have one.

One big hint: in your main() you don't call calculateGrossPay() anywhere.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.