wage = hours * rate for hours between 0 and <=40
= 380 + (hours - 40) * rate * 1.5 for hours >40 and <=60
= 665 + (hours - 60) * rate * 2.0 for hours >60
INPUT:
names = ['Sally','Joe','Nick','Nat','May','Wong','Lee','Zoe','Jie','Jay','Kent','Adam']
hours = [10, 15, 20, 25, 30, 30, 35, 45, 60, 65, 55, 40]
wages = [0.00] * len (names)
rate = 9.50
total_wages = 0.00
print ('\n\t PAYROLL RESULTS\t')
print ('')
print('{}.\t{}\t{}\t{}'.format('No', 'Employee name', 'Hours', 'Salary(RM)'))
for i in range (12):
if (hours[i] > 60):
wages[i] = 665 + (hours[i] - 60) * rate * 2.0
elif (hours[i] > 40):
wages[i] = 380 + (hours[i] - 40) * rate * 1.5
else:
wages[i] =hours[i] * rate
total_wages = total_wages + wages[i]
print ('{0}.\t{1}\t\t{2}\t{3:.2f}'.format(i+1, names[i], hours[i], wages[i]))
print('')
print ('Total salary = RM {0:.2f}'.format(total_wages))
OUTPUT:
PAYROLL RESULTS
No. Employee name Hours Salary(RM)
1. Sally 10 95.00
2. Joe 15 142.50
3. Nick 20 190.00
4. Nat 25 237.50
5. May 30 285.00
6. Wong 30 285.00
7. Lee 35 332.50
8. Zoe 45 451.25
9. Jie 60 665.00
10. Jay 65 760.00
11. Kent 55 593.75
12. Adam 40 380.00
Total salary = RM 4417.50
No comments:
Post a Comment