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

Write a program that uses the following arrays: • empId: an array of seven long

ID: 3764209 • Letter: W

Question

Write a program that uses the following arrays: • empId: an array of seven long integers to hold employee identification numbers. The array should be initialized with the following numbers: 5658845 4520125 7895122 8777541 8451277 1302850 7580489 • 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 wages The program should relate the data in each array through the subscripts. For example, the number in element 0 of the hours array should be the number of hours worked by 450 Chapter 7 Arrays Programming Challenges 451 the employee whose identification number is stored in element 0 of the empId array. That same employee’s pay rate should be stored in element 0 of the payRate array. 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, th

Explanation / Answer

Complete Program:

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

int main()
{
const int SIZE = 7;
long int empId[SIZE] = {5658845, 4520125, 7895122, 8777541, 8451277,1302850, 7580489};
int hours[SIZE];
double payRate[SIZE];
double wages[SIZE];

for(int i = 0; i < SIZE; i++)
{
  cout << " Enter the hours worked for the employee " << empId[i] << ": ";
  cin >> hours[i];

  while(hours[i] < 0)
  {
   cout << "The hours should not be negative value" << endl;
   cout << "Re-enter the hours worked for the employee " << empId[i] << ": ";
   cin >> hours[i];
  }

  cout << "Enter the pay rate for the employee " << empId[i] << ": ";
  cin >> payRate[i];

  while(payRate[i] < 6.00)
  {
   cout << "The pay rate should be >= 6.00" << endl;
   cout << "Re-enter the pay rate for the employee " << empId[i] << ": ";
   cin >> payRate[i];
  }

  wages[i] = hours[i] * payRate[i];
}

cout << endl << endl;
cout << left << setw(15) << "EmployeeIDs" << right << setw(15) << "GrossWages" << endl;
cout << "-------------------------------" << endl;
for(int i = 0; i < SIZE; i++)
{
  cout << left << setw(15) << fixed << empId[i] << right << setw(15) << setprecision(2) << fixed << wages[i] << endl;
}

cout << endl;
system("pause");
return 0;
}

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