Reputation: 3
Hey guys I have to do this payroll program for my programming class, but I'm about to fry my brain, because I can't get to do some if statements with the conditions my assignment is asking for. Here's what I have to do
Salespeople at SoftwarePirates get paid a base salary of $2000 per month. Beyond the base salary, each salesperson earns commission on the following scale:
Sales | Commission Rate | Bonus <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
The following additional conditions apply:
- If a salesperson has taken more than 3 vacation days in a month, their pay gets reduced by $200
- A salesperson earns a bonus only if they have been with the company for 3 months or more
- For salespeople who have been with the company for more than 5 years and who have made sales greater than $100,000 an additional bonus of $1000 is added
Here's the code I've had so far(it's pretty messy, but I can only use if statements, not while loop or stuff like that since we are following the class book)
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()
Thank you, hope anyone can guide me through this! I just don't know how to apply the conditions to the final gross pay.
Upvotes: 0
Views: 1604
Reputation: 32736
You're writing your if
conditions with multiple checks wrong. When you need to check multiple conditions, you are doing this:
if foo > 0 and < 60:
# then...
But you should be doing:
if foo > 0 and foo < 60:
# then..
or like this:
if 0 < foo < 60:
# then...
Upvotes: 2