Ask Question
1 December, 08:57

Now imagine that we have a list of 5 employees who have each worked 45, 15, 63, 23, and 39 hours. We'll fix rate_of_pay at 10. Payroll wants to mail checks for each of these employees. Use a definite loop (for loop) to loop through the list of employee hours and print the appropriate pay statement. Your output should look something like: Paying 475.0 by direct deposit Paying 150.0 by mailed check Paying 630.0 by direct deposit Paying 230.0 by mailed check Paying 390.0 by direct deposit

+4
Answers (1)
  1. 1 December, 10:48
    0
    Hi there! The question is asking for a simple loop implementation that prints payment advice for Payroll.

    Explanation:

    Assuming that the payment method is "mailed check" for hours worked less than 30 and "direct deposit" for hours worked greater than 30, we can implement the function as below.

    hours_worked = [45, 15, 63, 23, 39]

    payment_method = "mailed check"

    for (int index = 0; index < 5; index++) {

    if hours_worked[index] > 30 {

    payment_method = "direct deposit"

    }

    print ("Paying " + (hours_worked[index] * pay_rate) + "by " + payment_method)

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Now imagine that we have a list of 5 employees who have each worked 45, 15, 63, 23, and 39 hours. We'll fix rate_of_pay at 10. Payroll ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers