嘿伙计们我必须为我的编程课做这个工资单程序,但是我要炸掉我的大脑,因为如果我的作业所要求的条件声明,我就无法做一些事情。 。这是我必须做的事情
SoftwarePirates的销售人员每月可获得2000美元的基本工资。超过基本工资,每个销售人员都可以获得佣金 以下比例:
销售|佣金率|奖金 < 10000 | 0%| 0
10000 - $ 100,000 | 2%| 0
$ 100,001 - $ 500,00 | 15%| $ 1000
$ 500,001 - $ 1,000,000 | 28%| $ 5000
$ 1,000,000 | 35%| $ 100,000
以下附加条件适用:
- 如果销售人员一个月内休假超过3个,他们的工资将减少200美元
- 销售人员只有在公司工作3个月或以上才能获得奖金
- 对于已经在公司工作超过5年且销售额超过10万美元的销售人员 奖金为1000美元
醇>
这是我到目前为止所拥有的代码(它非常混乱,但我只能使用if语句,而不是循环或类似的东西,因为我们正在关注课本)
name = input("What's your name? ")
time = int(input("Enter the amount of months you've been working for SoftwarePirates Inc.: "))
vacation = input('Have you taken more than 3 days of vacations(yes or no) ')
sales = float(input("What were your sales this year? "))
def comissionOne():
base = 24000
print("Your commision rate is 0%, so your salary for the year is $", base)
if time <=3:
print("No bonus earned")
if vacation == 'yes':
print ("Your salary is reduced by $200 for taking more than 3 days off, leaving you at $", (base-200))
elif vacation == 'no':
print()
def comissionTwo():
base = 24000
print("Your commision rate is 2%, so your salary for the year is $", (base*0.02 + base))
if time <=3:
print("No bonus earned")
if vacation == 'yes':
print ("Your salary is reduced by $200 for taking more than 3 days off, leaving you at $", (base*0.02 + (base-200)))
elif vacation == 'no':
print()
def comissionThree():
print("Your commision rate is 15%, so your salary for the year is $", (base*0.15 + base))
if time <=3:
print("No bonus earned")
elif time > 3 and < 60:
print("Bonus of $1000 earned")
elif time >= 60:
print("Bonus of $1000 for being in the company for over 5 years")
if vacation =='yes':
print ("Your salary is reduced by $200 for taking more than 3 days off, leaving you at $", (base*0.15 + (base-200)))
elif vacation == 'no':
print()
def main():
print("Hi", name)
if sales < 10000:
comissionOne()
elif sales >=10000 and sales <=100000:
comissionTwo()
elif sales >=100001 and sales <=500000:
comissionThree()
elif sales >=500001 and sales <=1000000:
print("Your commision rate is 28%, so your salary for the year is $", (base*0.28 + base))
elif sales >=1000001:
print("Your commision rate is 35%, so your salary for the year is $", (base*0.35 + base))
main()
谢谢,希望有人能指导我完成这个!我只是不知道如何将条件应用于最终总薪酬。
答案 0 :(得分:2)
您正在编写多个检查错误的if
条件。当您需要检查多个条件时,您正在执行此操作:
if foo > 0 and < 60:
# then...
但你应该这样做:
if foo > 0 and foo < 60:
# then..
或者像这样:
if 0 < foo < 60:
# then...