Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that uses thefollowing arrays: empId: an array of seven long int

ID: 3617628 • Letter: W

Question

Write a program that uses thefollowing arrays:
  • empId: an array of seven long integers to holdemployee identification numbers. The array should be initializedwith the following numbers: 5658845, 4520125, 7895122, 8777541,8451277, 1302850, 7580489
  • hours: an array of seven integers to hold thenumber of hours worked by each employee
  • payRate: an array of seven floats to hold eachemployee's hourly pay rate
  • wages: an array of seven floats to hold eachemployee's gross wages.
The program should relate the data in each array through thesubscripts. For example, the number in element 0 of the 'hours'array should be the number of hours worked by the employee whoseidentification number is stored in element 0 of the 'empId' array.That same employee's pay rate should be stored in element 0 of thepayRate array. The program should display each employee number andask the user to enter that employee's hours and pay rate. It shouldthen calculate the gross wages for that employee (hours times payrate), which should be stored in the 'wages' array. After the datahas been entered for all the employees, the program should displayeach employee's identification number and gross wages. InputValidation: Do not accept negative values for hours or numbers lessthan 6.00 for pay rate. Start with the following code for themain function: int main()
{ const int size = 7;
long empId[size] = {5658845, 4520125, 7895122, 8777541,8451277, 1302850, 7580489};
int hours[size];
float payRate[size], wages[size];
getWages(empId, hours, payRate, wages, size); displayWages(empId,wages, size);
return 0; }
int main()
{ const int size = 7;
long empId[size] = {5658845, 4520125, 7895122, 8777541,8451277, 1302850, 7580489};
int hours[size];
float payRate[size], wages[size];
getWages(empId, hours, payRate, wages, size); displayWages(empId,wages, size);
return 0; }


Explanation / Answer


#include<iostream.h> #include<conio.h> void getWages(long [],int [], float [], float [],const); void displayWages(long [], float [], const); int main() { clrscr(); const int size = 7; long empId[size] = {5658845, 4520125, 7895122, 8777541,8451277, 1302850, 7580489}; int hours[size]; float payRate[size], wages[size]; getWages(empId, hours,payRate,wages,size); displayWages(empId, wages, size); getch(); return 0; } void displayWages(long *eid, float *wages, const s) { cout<<" Employee Id Wages"; cout<<endl<<"************************************"; int v; for(v=0;v<s;v++) cout<<endl<<eid[v]<<" "<<"$:"<<wages[v]; }
void getWages(long *eid,int *h,float *pr,float *wages,consts) { int v=0; float num; cout<<"Enter the info for each of the followingemployees identified by their ID Numbers: "; while(v<s) { cout<<" Employee Number: "<<eid[v]; cout<<" # of hours worked: "; cin>>h[v]; if(h[v]<0) { cout<<" Invalid data"; continue; } cout<<" Enter Pay Rate: "; cin>>pr[v]; if(pr[v]<6) { cout<<" Invalid Pay Rate"; continue; } else wages[v]=pr[v]*h[v]; v++; } }
Dev C++ compiler code is givenbelow:- (un-tested)
#include<iostream> using namespacestd; void getWages(long [],int [],float [], float [], const); void displayWages(long [], float[], const); int main() { const int size =7; long empId[size] = {5658845, 4520125, 7895122,8777541, 8451277, 1302850, 7580489}; int hours[size]; float payRate[size], wages[size]; getWages(empId,hours,payRate,wages,size); displayWages(empId, wages, size); system("pause"); return 0; } void displayWages(long *eid, float *wages, consts) { cout<<" Employee Id Wages"; cout<<endl<<"************************************"; int v; for(v=0;v<s;v++) cout<<endl<<eid[v]<<" "<<"$:"<<wages[v]; }
void getWages(long *eid,int *h,float *pr,float*wages,const s) { int v=0; float num; cout<<"Enter the info for each of the followingemployees identified by their ID Numbers: "; while(v<s) { cout<<" Employee Number:"<<eid[v]; cout<<" # of hours worked: "; cin>>h[v]; if(h[v]<0) { cout<<" Invalid data"; continue; } cout<<" Enter Pay Rate: "; cin>>pr[v]; if(pr[v]<6) { cout<<" Invalid Pay Rate"; continue; } else wages[v]=pr[v]*h[v]; v++; } }
#include<iostream.h> #include<conio.h> void getWages(long [],int [], float [], float [],const); void displayWages(long [], float [], const); int main() { clrscr(); const int size = 7; long empId[size] = {5658845, 4520125, 7895122, 8777541,8451277, 1302850, 7580489}; int hours[size]; float payRate[size], wages[size]; getWages(empId, hours,payRate,wages,size); displayWages(empId, wages, size); getch(); return 0; } void displayWages(long *eid, float *wages, const s) { cout<<" Employee Id Wages"; cout<<endl<<"************************************"; int v; for(v=0;v<s;v++) cout<<endl<<eid[v]<<" "<<"$:"<<wages[v]; }
void getWages(long *eid,int *h,float *pr,float *wages,consts) { int v=0; float num; cout<<"Enter the info for each of the followingemployees identified by their ID Numbers: "; while(v<s) { cout<<" Employee Number: "<<eid[v]; cout<<" # of hours worked: "; cin>>h[v]; if(h[v]<0) { cout<<" Invalid data"; continue; } cout<<" Enter Pay Rate: "; cin>>pr[v]; if(pr[v]<6) { cout<<" Invalid Pay Rate"; continue; } else wages[v]=pr[v]*h[v]; v++; } }
Dev C++ compiler code is givenbelow:- (un-tested)
#include<iostream> using namespacestd; void getWages(long [],int [],float [], float [], const); void displayWages(long [], float[], const); int main() { const int size =7; long empId[size] = {5658845, 4520125, 7895122,8777541, 8451277, 1302850, 7580489}; int hours[size]; float payRate[size], wages[size]; getWages(empId,hours,payRate,wages,size); displayWages(empId, wages, size); system("pause"); return 0; } void displayWages(long *eid, float *wages, consts) { cout<<" Employee Id Wages"; cout<<endl<<"************************************"; int v; for(v=0;v<s;v++) cout<<endl<<eid[v]<<" "<<"$:"<<wages[v]; }
void getWages(long *eid,int *h,float *pr,float*wages,const s) { int v=0; float num; cout<<"Enter the info for each of the followingemployees identified by their ID Numbers: "; while(v<s) { cout<<" Employee Number:"<<eid[v]; cout<<" # of hours worked: "; cin>>h[v]; if(h[v]<0) { cout<<" Invalid data"; continue; } cout<<" Enter Pay Rate: "; cin>>pr[v]; if(pr[v]<6) { cout<<" Invalid Pay Rate"; continue; } else wages[v]=pr[v]*h[v]; v++; } }
#include<iostream> using namespacestd; void getWages(long [],int [],float [], float [], const); void displayWages(long [], float[], const); int main() { const int size =7; const int size =7; long empId[size] = {5658845, 4520125, 7895122,8777541, 8451277, 1302850, 7580489}; int hours[size]; float payRate[size], wages[size]; getWages(empId,hours,payRate,wages,size); displayWages(empId, wages, size); system("pause"); return 0; } void displayWages(long *eid, float *wages, consts) { cout<<" Employee Id Wages"; cout<<endl<<"************************************"; int v; for(v=0;v<s;v++) cout<<endl<<eid[v]<<" "<<"$:"<<wages[v]; }
void getWages(long *eid,int *h,float *pr,float*wages,const s) { int v=0; float num; cout<<"Enter the info for each of the followingemployees identified by their ID Numbers: "; while(v<s) { cout<<" Employee Number:"<<eid[v]; cout<<" # of hours worked: "; cin>>h[v]; if(h[v]<0) { cout<<" Invalid data"; continue; } cout<<" Enter Pay Rate: "; cin>>pr[v]; if(pr[v]<6) { cout<<" Invalid Pay Rate"; continue; } else wages[v]=pr[v]*h[v]; v++; } }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote