-
Notifications
You must be signed in to change notification settings - Fork 0
/
SalaryChange
34 lines (30 loc) · 1.29 KB
/
SalaryChange
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Prepared by David P. Jurist
# Greenwood Village, Colorado, USA, 80111
# david.jurist@csuglobal.edu
# March 22, 2018
# MIS/DA Department, Colorado State University -- Global
# Define salary factor constant and state table
SALARY_RAISE_FACTOR = 0.05
STATE_CODE_MAP = {'WA': 'Washington', 'TX': 'Texas'}
# Begin script for Salary class, define update_employee_record function
class Salary:
def update_employee_record(rec):
old_sal = rec['salary']
new_sal = old_sal * (1 + SALARY_RAISE_FACTOR)
rec['salary'] = new_sal
state_code = rec['state_code']
rec ['state_name'] = STATE_CODE_MAP[state_code]
# Assign new data values to records for employee names, salaries and states
input_data = [
{'employee_name': 'Susan', 'salary': 100000.0, 'state_code': 'WA'},
{'employee_name': 'Ellen', 'salary': 75000.0, 'state_code': 'TX'},
]
# Execute loop for each rec element in the input_data array, assigning new string values and printing results
for rec in input_data:
update_employee_record(rec)
name = rec['employee_name']
salary = rec['salary']
state = rec['state_name']
print(name + ' now lives in ' + state)
# print( 'and makes %body#039; + str(salary)) This was the original erroneous line of code
print( 'and makes $' + str(salary)) # This is the revised, corrected line of code