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.
{ 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++; } }
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.