In: Computer Science
Write a complete and syntactically correct Python program to solve the following problem: You are the payroll manager for SoftwarePirates Inc. You have been charged with writing a package that calculates the monthly paycheck for the salespeople. 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,000 15% $1000 $500,001 - $1,000,000 28% $5000 >$1,000,000 35% $100,000 The following additional conditions apply: 1. If a salesperson has taken more than 3 vacation days in a month, their pay gets reduced by $200 2. A salesperson earns a bonus only if they have been with the company for 3 months or more 3. For salespeople who have been with the company for 5 years or more and who have made sales greater than $100,000 an additional bonus of $1000 is added. All input to the program will be interactive from the keyboard. The output of the program will include: a. The name of the salesperson b. Their longevity with the company c. Their base salary d. The commission earned (in Dollars) e. The bonus earned f. Additional bonus earned (if any) g. Deductions (if any) h. A total gross paycheck i. Your output should look like a paystub (NOT in paragraph format) j. All currency should be formatted with a $ sign and 2 decimal places
'''
Python version : 2.7
Python program to calculate the monthly paycheck for the salespeople.
'''
print('Payroll manager for SoftwarePirates Inc\n')
# input of name
name = raw_input('Enter your name : ')
# input of number of vacation days taken
vacation_days = int(raw_input('Number of vacation days taken : '))
# input of number of months with the company
longevity = int(raw_input('Number of months with the company : '))
# input of sales amount for the month
sales = float(raw_input('Enter sales amount : '))
# set the base salary
base_salary = 2000;
salary = base_salary
# calculate the number of years and months with the company
years = int(longevity/12)
months = (longevity - (12*years))
# set variables for deduction, additional_bonus and commission
deduction = 0
additional_bonus = 0
commission = 0
# calculate the commission_percent and bonus based on the sales
if sales < 10000 :
commission_percent = 0
bonus = 0
elif sales <= 100000 :
commission_percent = 0.02
bonus = 0
elif sales <=500000 :
commission_percent = 0.15
bonus = 1000
elif sales <= 1000000:
commission_percent = 0.28
bonus = 5000
else:
commission_percent = 0.35
bonus = 100000
# calculate total commission
commission =(sales*commission_percent)
# determine deduction
if vacation_days > 3 :
deduction = 200
# determine if bonus is applicable or not
if longevity < 3:
bonus = 0
# determine additional_bonus
if( (longevity >= 60) and (sales > 100000)):
additional_bonus = 1000
# calculate gross salary for the month
salary = base_salary + commission - deduction + additional_bonus
# output the data
print('\nName of the salesperson : '+name)
if(years > 0 and months > 0):
print('Longevity with the company : %d years %d months'%(years,months))
elif(years > 0):
print('Longevity with the company : %d years '%(years))
else:
print('Longevity with the company : %d months '%(months))
print('Base Salary : $%.2f' %(base_salary))
print('The commission earned: $%.2f' %(commission))
if(bonus > 0):
print('The bonus earned : $%.2f' %(bonus))
if(additional_bonus > 0):
print('Additional bonus earned $%.2f' %(additional_bonus))
if(deduction > 0):
print('Deductions : $%.2f' %(deduction))
print('Total gross paycheck :$%.2f '%(salary))
#end of program
Code Screenshot:
Output: