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

q4) CONSIDER THE FOLLOWING CODE: Using the following input: 10, 17, 45, 20, 35,

ID: 3810037 • Letter: Q

Question

q4)

CONSIDER THE FOLLOWING CODE:
Using the following input: 10, 17, 45, 20, 35, 20
void Question()
{
      int Employees = 3;
      double PayRate;
      double GrossPay;
      double OverTime;
      int Hours;
      cout << "Enter the hours worked by " << Employees <<
     " who all earn the same hourly rate :" << endl;
      for (int index = 0; index < Employees; index++)
      {
            cout << "Employee # " << (index + 1) << " :";
            cin >> Hours;
            cout << "Enter each Employee hourly rate:";
            cin >> PayRate;
            if (Hours > 40)
            {
                  GrossPay = 40 * PayRate;
                  OverTime = ((Hours - 40)*(1.5 * PayRate));
                  GrossPay += OverTime;
            }
            else
                  GrossPay = Hours * PayRate;
            cout << "Employee # " << (index + 1) << " :$ " <<
                   GrossPay << endl;
      }
}

GrossPay values are:

Select one:

a. Employee # 1 :$ 170
Employee # 2 :$ 850
Employee # 3 :$ 720

b. Employee # 1 :$ 150
Employee # 2 :$ 850
Employee # 3 :$ 710

c. Employee # 1 :$ 100
Employee # 2 :$ 850
Employee # 3 :$ 700

d. Employee # 1 :$ 170
Employee # 2 :$ 950
Employee # 3 :$ 700

please explain how you get the answer. Thank you

Explanation / Answer

Gross Pay values are

d. Employee # 1 :$ 170
Employee # 2 :$ 950
Employee # 3 :$ 700

The loop runs thrice. So the first set of values 10 and 17 will make = 10 *17 = 170

The second set of values 45 and 20. Because the hourly rate us 40 = (45*20) + ((40-45)*1.5*20) = 950

The thrid set of values 35 and 20 = (35*20) = 700