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

Language is C++ USCorp is a company who needs a program to calculate how much to

ID: 3784119 • Letter: L

Question

Language is C++

USCorp is a company who needs a program to calculate how much to pay their hourly paid employees. The following restrictions apply:

1- The US Department of Labor requires that employees to get paid time and a half for any hours over 40/week. For example, if an employee works 50 hours per week, they get 10 hours of overtime, at 1.5 times their base pay.

2- The State of Missouri requires that hourly employees be paid at least $7.65 an hour.

3- USCorp requires that an employee not work more than 60 hours in a week.

Rules:

- An employee gets paid (hours worked) . (base pay), for each hour up to 40 hours.

- The employee gets paid overtime = (base pay) . 1.5 for every hour over 40.

- The base pay must not be less than the minimum wage ($7.65 an hour). Print an error message otherwise.

- If the number of hours is greater than 60, print an error message.

Directions:

In a loop ask the user to enter the name of the employee, the base pay rate, and the number of hours worked. Calculate the total pay and print it for each employee, or print a message if the base pay is less than the minimum wage or the number of hours exceed the limit. The program should be able to run until the user chooses to exit.

Example run:

Enter the name of employee?

>> Janet

Enter the base pay rate per hour?

>> 8

Enter the number of hours worked per week?

>> 30

Janet’s total pay per week is $240.

To calculate the total pay for another employee press 1, to exit press 0.

>> 1

Enter the name of employee?

>> John

Enter the base pay rate per hour?

>> 7

Enter the number of hours worked per week?

>> 50

John’s base pay rate is less than the minimum wage.

To calculate the total pay for another employee press 1, to exit press 0.

>> 0

Thank you!

Language is C++

Explanation / Answer

PROGRAM CODE:

#include <iostream>
using namespace std;

int main() {
   string name;
   double basePayRate, numberOfHoursWorked, totalPay;
   int choice = 1;
   while(choice==1)
   {
       cout<<"Enter the name of employee?"<<endl<<">> ";
       cin>>name;
       cout<<"Enter the base pay rate per hour?"<<endl<<">> ";
       cin>>basePayRate;
       cout<<"Enter the number of hours worked per week?"<<endl<<">> ";
       cin>>numberOfHoursWorked;
       if(basePayRate < 7.65)
       {
           cout<<name<<"'s base pay rate is less than the minimum wage.";

       }
       else if(numberOfHoursWorked > 60)
       {
           cout<<name<<"'s working hours is more than 60.";
       }
       else
       {   if(numberOfHoursWorked<=40)
               totalPay = basePayRate*numberOfHoursWorked;
           else
               totalPay = 40*numberOfHoursWorked + (numberOfHoursWorked-40)*1.5*basePayRate;
           cout<<name<<"'s total pay per week is $"<<totalPay<<"."<<endl;
       }
      
       cout<<"To calculate the total pay for another employee press 1, to exit press 0."<<endl<<">> ";  
       cin>>choice;
   }
   return 0;
}

OUTPUT: