Ask Question
20 August, 03:24

Python Assume the input data is structured as follows: first there is a non-negative integer specifying the number of employee timesheets to be read in. This is followed by data for each of the employees. The first number for each employee is an integer that specifies their pay per hour in cents. Following this are 5 integers, the number of hours they worked on each of the days of the workweek. Given this data, write a loop and any necessary code that reads the data and stores the total payroll of all employees into the variable total. Note that you will have to add up the numbers worked by each employee and multiply that by that particular employee's pay rate to get the employee's pay for the week- - and sum those values into total.

+4
Answers (1)
  1. 20 August, 05:10
    0
    total_hours = 0

    total = 0

    n = int (input ("Enter the number of employees: "))

    for i in range (n):

    pay = int (input ("Enter the pay per hour in cents of the " + str (i+1) + ". employee: "))

    for j in range (5):

    hour = int (input ("Enter the work hour in " + str (j+1) + ". day: "))

    total_hours + =hour

    total + = pay * total_hours

    total_hours = 0

    print (total)

    Explanation:

    Initialize the total hours and total as 0

    Ask the user to enter the number of employees

    Create a nested for loop. The outer loop iterates depending on the number of employees. The inner loop iterates for each work day.

    Inside the outer loop, ask the employee's pay per hour. Then, inside the inner loop, ask for the work hours for 5 days. Sum the hours and assign the value to total hours.

    When inner loop is done, multiply the pay with total hours to calculate the pay and add this value to the total for each employee. Also, set the total hours as 0 (For the next employee, total hours will be zero at the beginning).

    When the loops are done, print the total
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Python Assume the input data is structured as follows: first there is a non-negative integer specifying the number of employee timesheets ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers