Ask 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 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

+2
Answers (1)
  1. 17 October, 21:55
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers