In: Computer Science
How to write this Python
You are a small business owner and you have six employees. All the
employees have the same pay rate, that is $12 per hour. Write a
program that will ask the user to enter the number of hours worked
by each employee, then display the amounts of gross pay for each
employee.
1. Get the number of worked hours for each employee and store it in a list. 2. Use the stored value in each element to calculate the gross pay for each employee and display the amount. 3. Match your output format to the below sample output.
Answer should look like this
Enter the hours worked by employee 1: 20 Enter the hours worked by employee 2: 25 Enter the hours worked by employee 3: 29 Enter the hours worked by employee 4: 30 Enter the hours worked by employee 5: 20 Enter the hours worked by employee 6: 19 Enter the hourly pay rate: 12 Gross pay for employee 1: $240.00 Gross pay for employee 2: $300.00 Gross pay for employee 3: $348.00 Gross pay for employee 4: $360.00 Gross pay for employee 5: $240.00 Gross pay for employee 6: $228.00
If you have any doubts, please give me comment...
hours_worked = []
for i in range(1, 7):
hours = int(input("Enter the hours worked by employee "+str(i)+": "))
hours_worked.append(hours)
print()
pay_rate = int(input("Enter the hourly pay rate: "))
print()
for i in range(6):
print("Gross pay for employee %d: $%.2f"%(i+1, hours_worked[i]*pay_rate))