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 onedimensional array to store the names of all the employees Name
a twodimensional array of rows and 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 ;
const int COLS ;
Salary output: Show fixed two digits after decimal point setprecision
A sample output
Name Hrs Worked Pay Rate Salary
Johnson
Aniston
Cooper
Average Salary: $
Salary Greater than Avg:
Aniston Gupta Kennedy
this is my code so far:
#include
#include
#include
#include
using namespace std;
const int ROWS ;
const int COLS ;
Function prototypes
void readDatastring names double dataCOLS;
void computeWeeklyPaydouble dataCOLS;
void printEmployeeDataconst string names const double dataCOLS;
double computeAverageSalaryconst double dataCOLS;
void printAboveAverageconst string names const double dataCOLS double average;
int main
string namesROWS;
double dataROWSCOLS; : Hours Worked, : Pay Rate, : Salary
readDatanames data;
computeWeeklyPaydata;
printEmployeeDatanames data;
double average computeAverageSalarydata;
cout "Average Salary: $ fixed setprecision average endl;
cout "Salary Greater than Avg:" endl;
printAboveAveragenames data, average;
return ;
Function to read data from file
void readDatastring names double dataCOLS
ifstream inputFileemployeeDatatxt;
if inputFile
cerr "Error opening file!" endl;
exit;
for int i ; i ROWS; i
inputFile namesi datai datai;
inputFile.close;
Function to compute weekly pay
void computeWeeklyPaydouble dataCOLS
for int i ; i ROWS; i
double hours datai;
double rate datai;
double overtime ;
if hours
overtime hours rate ;
hours ;
datai hours rate overtime;
Function to print each employee's data
void printEmployeeDataconst string names const double dataCOLS
cout left setw "Name"
right setwHrs Worked"
setw "Pay Rate"
setw "Salary" endl;
for int i ; i ROWS; i
cout left setw namesi
right setw fixed setprecision datai
setw datai
setw datai endl;
Function to compute the average salary
double computeAverageSalaryconst double dataCOLS
double total ;
for int i ; i ROWS; i
total datai;
return total ROWS;
Function to print names of employees with salary average
void printAboveAverageconst string names const double dataCOLS double average
for int i ; i ROWS; i
if datai average
cout namesi;
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 exited with code
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
