112k views
2 votes
Write a Python program that calculates an employee's annual bonus. Input is an employee's first name, last name, salary, and numeric performance rating. If the rating is 1, 2, or 3, the bonus rate used is .25, .15, or .1 respectively. If the rating is 4 or higher, the rate is 0. The employee bonus is calculated by multiplying the bonus rate by the annual salary.

1 Answer

3 votes

Answer:

Step-by-step explanation:

The following code is written in Python. It is a function that takes in the first name, last name, salary, and numeric performance rating of the employee. Then it uses the rating and the salary to calculate the bonus and returns that back to the user. A test case has been created and the output can be seen in the attached image below.

def calculate_bonus(first_name, last_name, salary, rating):

rate = 0;

if rating == 1:

rate = 0.25

elif rating == 2:

rate = 0.15

elif rating == 3:

rate = 0.1

else:

rate = 0

bonus = salary * rate

return bonus

Write a Python program that calculates an employee's annual bonus. Input is an employee-example-1
User Bentrm
by
5.7k points