Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 我的奖金计算器出错_Python - Fatal编程技术网

Python 我的奖金计算器出错

Python 我的奖金计算器出错,python,Python,以下是我目前的代码: # This program will determine the appropriate bonus to be given to both the store # and the employess. # Lab 3-4 # The main function def main(): monthlySales = getSales() # Call to get sales salesIncrease = getIncrease() # Call t

以下是我目前的代码:

# This program will determine the appropriate bonus to be given to both the store
# and the employess.

# Lab 3-4

# The main function
def main():
    monthlySales = getSales() # Call to get sales
    salesIncrease = getIncrease() # Call to get sales increase
    storeAmount = storeBonus(monthlySales) # Call to get the store bonus
    empAmount = empBonus(monthlySales) # Call to get the employee bonus
    printBonus (storeAmount, empAmount) # Call to print amounts    

# This function gets the monthly sales
def getSales():
    monthlySales = input('Enter the monthly sales $')
    monthlySales = float(monthlySales)
    return monthlySales

# This function gets the percent of increase in sales
def getIncrease():
    salesIncrease = input('Enter percent of sales increase. For example, 4% should be entered as 4: ')
    salesIncrease = float(salesIncrease)
    salesIncrease = salesIncrease / 100
    return salesIncrease

# This function determines storeAmount bonus
def storeBonus(monthlySales):
    if monthlySales >=110000:
        storeAmount = 6000
    elif monthlySales >=100000:
        storeAmount = 5000
    elif monthlySales >=90000:
        storeAmount = 4000
    elif monthlySales >=80000:
        storeAmount = 3000
    else:
        storeAmount = 0
    return storeAmount

# This function determines empAmount bonus
def empBonus(salesIncrease):
    if salesIncrease >= .05:
        empAmount = 75
    elif salesIncrease >= .04:
        empAmount = 50
    elif salesIncrease >= .03:
        empAmount = 40
    else:
        empAmount = 0
    return empAmount

# This function prints the bonus information
def printBonus(storeAmount, empAmount):
    print('The store bonus is $', storeAmount)
    print('The employee bonus is $', empAmount)
    if storeAmount == 6000 and empAmount == 75:
        print('Congrats! You have reached the highest bonus amounts possible!')

# Calls main
main()
现在为了测试这段代码,我给出了以下场景:

1个月销售额=120500销售额增长=5

2个月销售额=93400销售额增长=5

3个月销售额=75000销售额增长=1.5

4个月销售额=82000销售额增长=3.6

5个月销售额=125000销售额增长=4.5

现在一切顺利,直到3-5。员工奖金金额不应该是75美元,但结果就是这样。关于如何解决这个问题有什么想法吗?有人在我的代码中看到我没有看到的错误吗

*编辑:对于每个输入值,代码应该输出的内容如下

1$6000$75

2$4000$75

3$0$0

4$3000$40


5$6000$50

很难说出你的问题是什么,因为你的问题无法解释你想做什么,但我可以冒昧地猜测你的差距是100倍:

def empBonus(salesIncrease):
    if salesIncrease >= 5:
        empAmount = 75
    elif salesIncrease >= 4:
        empAmount = 50
    elif salesIncrease >= 3:
        empAmount = 40
    else:
        empAmount = 0
    return empAmount

为了使用第三个示例,您检查了1.5>=0.05,这当然是正确的,因此EMPAUNT被设置为75。

有关更多信息,请参阅“*Edit:”。希望这能进一步澄清我的问题。我为最初的混乱道歉。