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

// Lab Exercise 11.1 // EmployeesOne.cpp // This program stores, in an array, th

ID: 3763378 • Letter: #

Question

// Lab Exercise 11.1
// EmployeesOne.cpp

// This program stores, in an array, the hours worked by
// employees who all make the same hourly wage and then
// prints a list of employee numbers and their gross pay.

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

int main()
{
   const int NUM_EMPLOYEES = 5;

   int hours[NUM_EMPLOYEES];
   double payrate;

   // Input the hours worked.

   cout << "Enter the hours worked by ";
   cout << NUM_EMPLOYEES << " employees ";
   cout << "who all earn the same hourly rate. ";

   //   TODO:   Write a FOR loop to input hours worked for
   //           each employee. Use a prompt for each
   //           employee that includes the employee number.

   // Input the hourly rate for all employees.

   cout << " Enter the hourly pay rate for all the employees: ";
   cin >> payrate;

   // Display each employee's gross pay.

   cout << " Here is the gross pay for each employee: ";
   cout << fixed << showpoint << setprecision(2);

   //   TODO:   Write a FOR loop to calculate the gross pay
   //           for each employee. The loop should then display
   //           the employee number and gross pay for each employee.

   return 0;
}

/* Sample output...

Enter the hours worked by 5 employees
who all earn the same hourly rate.
Employee #1: 40
Employee #2: 38
Employee #3: 40
Employee #4: 35
Employee #5: 20

Enter the hourly pay rate for all the employees: 10.50

Here is the gross pay for each employee:
Employee #1: $420.00
Employee #2: $399.00
Employee #3: $420.00
Employee #4: $367.50
Employee #5: $210.00

*/

Explanation / Answer

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
    const int NUM_EMPLOYEES = 5;

    int hours[NUM_EMPLOYEES];
    double payrate,amt;
    // Input the hours worked.

    cout << "Enter the hours worked by ";
    cout << NUM_EMPLOYEES << " employees ";
    cout << "who all earn the same hourly rate. ";
    // TODO: Write a FOR loop to input hours worked for
   for(i=0;i<NUM_EMPLOYEES;i++)
   {
       cout<<"Emplyee #<<i+1;
       cin>>hours[i];
   }
    // each employee. Use a prompt for each
    // employee that includes the employee number.



    // Input the hourly rate for all employees.
    cout << " Enter the hourly pay rate for all the employees: ";
    cin >> payrate;
    // Display each employee's gross pay.
    cout << " Here is the gross pay for each employee: ";
    cout << fixed << showpoint << setprecision(2);
   for(i=0;i<NUM_EMPLOYEES;i++)
   {
       amt=hours[i]*payrate;
       cout<<" Emplyee #<<i+1<<": "<<amt;
      
   }

    // TODO: Write a FOR loop to calculate the gross pay
    // for each employee. The loop should then display
    // the employee number and gross pay for each employee.



    return 0;
}