I'm sorry, I know similar questions have been asked but I'm not understanding the replies. Usually something to do with pointers, which we haven't learned about in my class.
Here is the program
#include <iostream>
using namespace std;
const int NUM_EMPLOYEES = 4;
void readData(string name[NUM_EMPLOYEES], double salary[NUM_EMPLOYEES]);
void updateCOL(double salary[NUM_EMPLOYEES], double COL);
double payroll(double salary[NUM_EMPLOYEES]);
int main()
{
string name[NUM_EMPLOYEES];
double salary[NUM_EMPLOYEES];
double COL;
readData(name, salary);
cout << "Cost of living?" << endl;
cin >> COL;
updateCOL(salary, COL);
for (int i = 0; i < NUM_EMPLOYEES; i++)
{
cout << name[i] << " $" << salary[i] << endl;
}
cout << endl
<< "Total Payroll: $" << payroll(salary) << endl;
return 0;
}
void readData(string name[NUM_EMPLOYEES], double salary[NUM_EMPLOYEES])
{
for (int i = 0; i < NUM_EMPLOYEES; i++)
{
cout << "Name salary? ";
cin >> name[i] >> salary[i];
cout << endl;
}
}
void updateCOL(double salary[NUM_EMPLOYEES], double COL)
{
for (int i = 0; i < NUM_EMPLOYEES; i++)
{
salary[i] = salary[i] + (COL / 100);
}
}
double payroll(double salary[NUM_EMPLOYEES])
{
double payroll = 0;
for (int i = 0; i < NUM_EMPLOYEES; i++)
{
payroll += salary[i];
}
return payroll;
}
Expected inputs and outputs are
Output: Name salary?
Input: John 32000
Output: Name salary?
Input: Jack 56000
Output: Name salary?
Input: Jane 65000
Output: Name salary?
Input: Jill 50000
Output: Cost of living?
Input: 2
Output:
John $32640
Jack $57120
Jane $66300
Jill $51000
Total payroll: $207060
But when on the final output, I'm just getting the inputs back without being updated. Thanks for the help in advance!