我有一个关于我的Python程序的问题。我无法在这个程序中找到总数和总数。休息工作正常。有什么办法可以解决这个问题吗?我很快就有了这个计划。我会很感激任何提示我可以得到:d感谢Python重复结构和文件
midSalary = 50000
maxSalary = 60000
def main():
inFile = open('program7.txt', 'r')
lineRead = inFile.readline()
total = 0.0
ntotal = 0.0
count = 0
while lineRead != '':
words = lineRead.split()
for word in words:
num = float(word)
total += num
count += 1
print("\nFaculty Member # ",count, ": $" , format(num, '.2f'), sep ="")
if num >= maxSalary:
payIncrease(num, .04)
elif num >= midSalary:
payIncrease(num, .07)
else:
payIncrease(num , .055)
lineRead = inFile.readline()
#averagePayRaise = (ntotal - total)/count
inFile.close()
for divider in range(45):
print("-", end ='')
print("\nTotal Faculty payroll : $", format(total , ",.2f"),sep ="")
print("The New Total Faculty payroll : $", format(ntotal , ",.2f"),sep ="")
print("Average Pay Raise : $", format(averagePayRaise, ",.2f"), sep ="")
def payIncrease(amount, prcnt):
print("Pay Raise Percent : ", format(prcnt*100, ".1f")+"%")
total = 0.0
ntotal = 0.0
count = 0
salRaise = amount * prcnt
newSal = amount + salRaise
print("Pay Raise : $", format(salRaise, ',.2f'), sep ="")
print("New Salary : $", format(newSal, ',.2f'), sep = "")
total += amount
count += 1
ntotal += newSal
averagePayRaise = (ntotal - total)/count
main()
我得到的解决方案为0为em – spuriousarbiter 2014-10-29 23:01:44
您能显示输入,预期输出和当前输出吗? – 2014-10-29 23:04:38
共有教师工资:$ 1,310,555.15 新的总工资单系:$ 0.00 平均加薪:$ -59,570.69 我得到下面说 – spuriousarbiter 2014-10-29 23:06:45