Question: these are my instructions: Use two parallel arrays: a one - dimensional array to store the names of all the employees ( Name ) a

these are my instructions:
Use two parallel arrays:
a one-dimensional array to store the names of all the employees (Name)
a two-dimensional array of 10 rows and 3 columns to store the number of hours an employee worked in a week (Hrs Worked), the hourly pay rate (Pay Rate), and the weekly pay (Salary).
Your program must contain at least the following functions:
a function to read the data from the file into the arrays.
a function to determine the weekly pay.
a function to output each employees data.
a function to output the average salary of all employees
a function to output the names of all the employees whose pay is greater than or equal to the average weekly pay
The only global variables are the array dimensions:
const int ROWS =10;
const int COLS =3;
Salary output: Show fixed two digits after decimal point setprecision(2).
A sample output
Name Hrs Worked Pay Rate Salary
Johnson 60.0012.50875.00
Aniston 65.0013.251026.88
Cooper 50.0014.50797.50
............
Average Salary: $947.88
Salary Greater than Avg:
Aniston Gupta Kennedy ...
this is my code so far:
#include
#include
#include
#include
using namespace std;
const int ROWS =10;
const int COLS =3;
// Function prototypes
void readData(string names[], double data[][COLS]);
void computeWeeklyPay(double data[][COLS]);
void printEmployeeData(const string names[], const double data[][COLS]);
double computeAverageSalary(const double data[][COLS]);
void printAboveAverage(const string names[], const double data[][COLS], double average);
int main(){
string names[ROWS];
double data[ROWS][COLS]; //0: Hours Worked, 1: Pay Rate, 2: Salary
readData(names, data);
computeWeeklyPay(data);
printEmployeeData(names, data);
double average = computeAverageSalary(data);
cout << "Average Salary: $"<< fixed << setprecision(2)<< average << endl;
cout << "Salary Greater than Avg:" << endl;
printAboveAverage(names, data, average);
return 0;
}
// Function to read data from file
void readData(string names[], double data[][COLS]){
ifstream inputFile("employeeData.txt");
if (!inputFile){
cerr << "Error opening file!" << endl;
exit(1);
}
for (int i =0; i < ROWS; i++){
inputFile >> names[i]>> data[i][0]>> data[i][1];
}
inputFile.close();
}
// Function to compute weekly pay
void computeWeeklyPay(double data[][COLS]){
for (int i =0; i < ROWS; i++){
double hours = data[i][0];
double rate = data[i][1];
double overtime =0.0;
if (hours >40){
overtime =(hours -40)* rate *1.5;
hours =40;
}
data[i][2]= hours * rate + overtime;
}
}
// Function to print each employee's data
void printEmployeeData(const string names[], const double data[][COLS]){
cout << left << setw(10)<< "Name"
<< right << setw(10)<<"Hrs Worked"
<< setw(10)<< "Pay Rate"
<< setw(10)<< "Salary" << endl;
for (int i =0; i < ROWS; i++){
cout << left << setw(10)<< names[i]
<< right << setw(10)<< fixed << setprecision(2)<< data[i][0]
<< setw(10)<< data[i][1]
<< setw(10)<< data[i][2]<< endl;
}
}
// Function to compute the average salary
double computeAverageSalary(const double data[][COLS]){
double total =0.0;
for (int i =0; i < ROWS; i++){
total += data[i][2];
}
return total / ROWS;
}
// Function to print names of employees with salary >= average
void printAboveAverage(const string names[], const double data[][COLS], double average){
for (int i =0; i < ROWS; i++){
if (data[i][2]>= average){
cout << names[i]<<"";
}
}
cout << endl;
}
here is my issue, I can't get rid of this error no matter how many paths I make to open the file. Am I missing something extremely basic in nature or making a silly mistake? "Error opening file! (process 23108) exited with code 1.
Press any key to close this window ..."
please help.
every single suggestion or idea so far has not changed the error including other chegg experts. running out of options.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!