这是我的程序。我正在为七名员工创建工资单。我试图实现一个循环,它从 num = 1 开始,一直到 num = 7。但是,当我运行程序时,什么都没有打印出来。想法?
#initalize all variables
medPremiere = 400
fedRate = .20
stateRate = .05
FICA = .08
retirement = .06
**Tax rates and such**
#the processing module
num = 1
while num < 8:
if num ==1:
empNum = 1
empName = 'billybob'
hours = 40
rate = 50
num = num + 1
if num ==2:
empNum = 2
empName = 'superman'
hours = 55
rate = 40
num = num + 1
if num ==3:
empNum = 3
empName = 'hulk'
hours = 60
rate = 60
num = num + 1
if num ==4:
empNum = 4
empName = 'scoobie'
hours = 45
rate = 80
num = num + 1
if num ==5:
empNum = 5
empName = 'Sherry'
hours = 66
rate = 30
num = num + 1
if num ==6:
empNum = 6
empName = 'doctor'
hours = 88
rate = 90
num = num + 1
if num ==7:
empNum = 7
empName = 'ironman'
hours = 77
rate = 70
num = num + 1
这些是 7 位不同的员工,我必须为其创建 #the calc 模块的工资单
#calculate gross pay
num ==1
while num < 8:
They get payed overtime and double overtime so I have to account for how many hours each employee has worked. Less than 41 hours they get payed regular, 41-60 hours they get paid overtime and more than 61 hours they get payed double overtime.
if hours <41:
gross = rate*hours
fedTax = gross*fedRate
stateTax = gross*stateRate
F = gross*FICA
K = gross*retirement
netPay = gross - fedTax - stateTax - F - K - medPremiere
print('Gross pay: ', gross)
print('Federal tax @ 20%: ', fedTax)
print('State tax @ 5%: ', stateTax)
print('FICA @ 8%: ', F)
print('401K @ 6%: ', K)
print('Net pay: $', netPay)
num = num + 1
在这里,我试图让它回到顶部的数字列表并为下一个员工提取信息。
if hours < 61:
gross = (40*hours) + (hours - 40)(1.5)(rate)
fedTax = gross*fedRate
stateTax = gross*stateRate
F = gross*FICA
K = gross*retirement
netPay = gross - fedTax - stateTax - F - K - medPremiere
print('Gross pay: ', gross)
print('Federal tax @ 20%: ', fedTax)
print('State tax @ 5%: ', stateTax)
print('FICA @ 8%: ', F)
print('401K @ 6%: ', K)
print('Net pay: $', netPay)
num = num + 1
if hours > 61:
gross = 40*hours + (hours-40)(1.5)(rate) + (hours - 60)(2)(rate)
fedTax = gross*fedRate
stateTax = gross*stateRate
F = gross*FICA
K = gross*retirement
netPay = gross - fedTax - stateTax - F - K - medPremiere
print('Gross pay: ', gross)
print('Federal tax @ 20%: ', fedTax)
print('State tax @ 5%: ', stateTax)
print('FICA @ 8%: ', F)
print('401K @ 6%: ', K)
print('Net pay: $', netPay)
num = num + 1
break
calc 模块的格式是否正确,还是有更好的方法来解决这个问题?