Week 3 - Expand Pseudo Code

The accounting office indicated the code must be able to handle overtime hours. Add functionality to your pseudo code so that if more than 40 hours are worked, the hours over 40 receive time and a half (1.5 * pay rate). Your new output will need to display the name, regular hours worked, overtime hours worked, normal pay, overtime pay, and total pay.

To add functionality for handling overtime hours in the pseudo code, you can modify the existing code as follows:

1. Declare variables:
- name (string) : representing the name of the employee
- hoursWorked (integer): representing the total hours worked by the employee
- payRate (float): representing the pay rate per hour
- regularHours (integer): representing the regular hours worked (up to 40 hours)
- overtimeHours (integer): representing the hours worked beyond 40 hours
- regularPay (float): representing the pay for regular hours worked
- overtimePay (float): representing the pay for overtime hours worked
- totalPay (float): representing the total pay including regular and overtime pay

2. Prompt the user to enter the name, hours worked, and pay rate:
- Read and assign the values to the corresponding variables.

3. Calculate the regular and overtime hours:
- If hoursWorked is greater than 40, assign 40 to regularHours and the remaining hours to overtimeHours.
- Otherwise, assign hoursWorked to regularHours and 0 to overtimeHours.

4. Calculate the regular and overtime pay:
- Multiply regularHours by payRate and assign the result to regularPay.
- Multiply overtimeHours by 1.5 times payRate and assign the result to overtimePay.

5. Calculate the total pay:
- Add regularPay and overtimePay and assign the result to totalPay.

6. Display the results:
- Display the name, regular hours worked, overtime hours worked, regular pay, overtime pay, and total pay.

Here's the expanded pseudo code with the added functionality for handling overtime hours:

```
Declare variables:
- name (string)
- hoursWorked (integer)
- payRate (float)
- regularHours (integer)
- overtimeHours (integer)
- regularPay (float)
- overtimePay (float)
- totalPay (float)

Prompt user for:
- name
- hoursWorked
- payRate

Calculate regular and overtime hours:
- If hoursWorked > 40, assign 40 to regularHours and (hoursWorked - 40) to overtimeHours
- Else, assign hoursWorked to regularHours and 0 to overtimeHours

Calculate regular and overtime pay:
- regularPay = regularHours * payRate
- overtimePay = overtimeHours * (1.5 * payRate)

Calculate total pay:
- totalPay = regularPay + overtimePay

Display results:
- Display name, regularHours, overtimeHours, regularPay, overtimePay, and totalPay
```

This updated pseudo code will be able to handle overtime hours calculation and display the relevant information accordingly.

To add functionality to the pseudo code to handle overtime hours, you can follow these steps:

Step 1: Modify the existing variables and add new variables:
- Add a new variable to store the overtime hours worked.
- Add a new variable to store the regular pay.
- Add a new variable to store the overtime pay.
- Add a new variable to store the total pay.

Step 2: Update the input section of the code:
- Prompt the user to enter the number of hours worked.
- Convert the input to a numeric value and assign it to the variable "hoursWorked".

Step 3: Calculate the regular hours and overtime hours:
- Use an "if" statement to check if the hours worked is greater than 40.
- If it is, subtract 40 from the total hours worked and assign the result to the overtime hours variable. Set the regular hours to 40.
- If it is not, assign the total hours worked to the regular hours and set the overtime hours to 0.

Step 4: Calculate the regular pay and overtime pay:
- Multiply the regular hours by the pay rate and assign the result to the regular pay variable.
- Multiply the overtime hours by 1.5 times the pay rate and assign the result to the overtime pay variable.

Step 5: Calculate the total pay:
- Add the regular pay and overtime pay together and assign the result to the total pay variable.

Step 6: Output the results:
- Display the name, regular hours worked, overtime hours worked, regular pay, overtime pay, and total pay.

Step 7: End the program.

Pseudo code example:

```
DECLARE name, hoursWorked, payRate, regularHours, overtimeHours, regularPay, overtimePay, totalPay

DISPLAY "Enter your name: "
INPUT name

DISPLAY "Enter the number of hours worked: "
INPUT hoursWorked

DISPLAY "Enter your pay rate: "
INPUT payRate

IF hoursWorked > 40 THEN
SET overtimeHours = hoursWorked - 40
SET regularHours = 40
ELSE
SET regularHours = hoursWorked
SET overtimeHours = 0
ENDIF

SET regularPay = regularHours * payRate
SET overtimePay = overtimeHours * (1.5 * payRate)
SET totalPay = regularPay + overtimePay

DISPLAY "Name: " + name
DISPLAY "Regular hours worked: " + regularHours
DISPLAY "Overtime hours worked: " + overtimeHours
DISPLAY "Regular pay: $" + regularPay
DISPLAY "Overtime pay: $" + overtimePay
DISPLAY "Total pay: $" + totalPay

END
```

Remember, this is a pseudo code and you would need to convert it to the actual programming language you are using.