In: Computer Science
Program must be in C++!
Write a program which: Write a program which uses the following arrays: empID: An array of 7 integers to hold employee identification numbers. The array should be initialized with the following values: 1, 2, 3, 4, 5, 6, 7. Hours: an array of seven integers to hold the number of hours worked by each employee. payRate: an array of seven doubles to hold each employee’s hourly pay rate. Wages: an array of seven doubles to hold each employee’s gross salary. The program should display each employee number and ask the user to enter that employee’s hours and pay rate. It should then calculate the gross wages for that employee (hours times pay rate) and store them in the wages array. After the data has been entered for all the employees, the program should display each employee’s identification number and gross wages. General Restrictions : No global variables No labels or go-to statements No infinite loops, examples include: for(;;) while(1) while(true) do{//code}while(1); No break statements to exit loops.
program:
#include <iostream>
using namespace std;
int main(){
int empID[] = {1,2,3,4,5,6,7};
int hours[7];
double payRate[7];
double wages[7];
for(int i = 0; i<7; i++){
cout<<"Enter hours of work
and pay rate of employee "<<empID[i];
cin>>hours[i]>>payRate[i];
wages[i] = payRate[i] *
hours[i];
}
cout<<"employee ID\twage\n";
for(int i = 0; i<7; i++){
cout<<empID[i]<<"\t\t"<<wages[i]<<"\n";
}
return 0;
}
sample input and output: