Problem Statement (Python)
You have been asked to write a program for a retail store that will allow them to calculate discounts for their employees when they buy items. Discounts are based on number of years worked as well as if the employee is a manager or hourly employee. They are also allowed no discount once they have received $200 in discounts for the year.
Note: Once you complete the discount for the employee, a question should be asked as to if there is another employee. If there is, collect the input and process the data for the next employee as such. Do this until the user answers “NO” for “Another Employee”. Once all employees have been processed, display the All Employee Summary and end the program.
INPUT
The application must be able to collect the following “required” information for each employee:
OUTPUT
There are two distinct areas required for output:
PROCESS
Employee discount standard
|
Years of Employment |
Management |
Hourly |
|
1-3 Years |
20% |
10% |
|
4-6 Years |
24% |
14% |
|
7-10 Years |
30% |
20% |
|
11-15 Years |
35% |
25% |
|
More than 15 Years |
40% |
30% |
YTD discount in dollars = total purchase before today * discount
Employee discount this purchase:
The discount for the purchased is based on the YTD discounts already realized. Meaning, an employee or manager only receives $200 in discount for the year.
Therefore:
Total with discount: Total * discount allowed
Program Screen Shot:



Sample Output:


Program Code to Copy:
# for all employee summary
total_all_before_discount = 0
total_all_after_discount = 0
# discount options
management_discount = [0.20,0.24,0.30,0.35,0.40]
employee_discount = [0.10,0.14,0.20,0.25,0.30]
another_employee = True
while another_employee:
# initialize the looping variables to invalid values
years = -1
previous_amount = -1
today_amount = -1
status = 'unknown'
# get inputs and validate until valid inputs are given
while years<=0:
years = int(input('Enter number of years employed: '))
while previous_amount<0:
previous_amount = float(input('Enter total amount of previous
purchases before discount($): '))
while not (status == 'manager' or status ==
'employee'):
status = input('Enter status (employee/manager) ?: ').lower()
while today_amount<0:
today_amount = float(input('Enter total of today’s purchase($):
'))
# get index to reference the discount options/table
if years>=1 and years<=3:
index = 0
elif years>=4 and years<=6:
index = 1
elif years>=7 and years<=10:
index = 2
elif years>=11 and years<=15:
index = 3
elif years>15:
index = 4
# reference the discount options using index and status
if status == 'manager':
discount_percentage = management_discount[index]
elif status == 'employee':
discount_percentage = employee_discount[index]
print('\nDiscount percentage is ',discount_percentage)
# YTD
ytd_amount_discount = previous_amount * discount_percentage
print('YTD Amount of discount in dollars is
$',ytd_amount_discount)
# total today
print('Total purchase today before discount is
$',today_amount)
# compute discount amount
current_discount = today_amount * discount_percentage
discount_this_purchase = 0
if ytd_amount_discount>=200:
discount_this_purchase = 0
elif (current_discount + ytd_amount_discount) < 200:
discount_this_purchase = current_discount
elif (current_discount + ytd_amount_discount) >= 200:
discount_this_purchase = 200 - ytd_amount_discount
print('Discount this purchase is $',discount_this_purchase)
total_with_discount = today_amount *
discount_this_purchase
print('Total with discount is $',total_with_discount)
# uodate the totals for all employees
total_all_before_discount = total_all_before_discount +
today_amount
total_all_after_discount = total_all_after_discount +
total_with_discount
# continuity
another_employee = input('\nAnother employee? (YES/NO): ').upper()
== 'YES'
print('-------------------------------------------------------------------')
# display all employees summary
print('\n****All Employee Summary****')
print('Total before discount for the day is
$',total_all_before_discount)
print('Total after discounts applied is
$',total_all_after_discount)
------------------------------------------------------------------------------
COMMENT DOWN FOR ANY QUERY RELATED TO THIS ANSWER,
IF YOU'RE SATISFIED, GIVE A THUMBS UP
~yc~
Problem Statement (Python) You have been asked to write a program for a retail store that...