In this lab, you complete 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.

Respuesta :

Answer:

The program is as follows (See attachment)

Comments are used to explain some lines

Fname = input("Enter Employee First Name: ")

Lname = input("Enter Employee Last Name: ")

Salary = float(input("Enter Employee Salary: "))

Ratings = int(float(input("Enter Employee Ratings: ")))

#Initialize bonus rate to 0; This will be used if ratings is 4 or 4

bonusRate = 0.0

if Ratings == 1:

       bonusRate =0.25 #If ratings is 1, bonus rate is 0.25

elif Ratings == 2:

       bonusRate = 0.15 #If ratings is 2, bonus rate is 0.15

elif Ratings == 3:

       bonusRate = 0.1 #If ratings is 3, bonus rate is 0.1

bonus = Salary * bonusRate

print(Lname+" "+Fname+"'s employee bonus is "+str(bonus))

#End of Program

Explanation:

The program saves the employee's first name and last name in variables Fname and Lname, respectively

The employee's salary is saved as float datatype in variable Salary

The employee's ratings is saved as int datatype in variable Ratings

For ratings greater than or equal to 4, the bonusRate is set to 0.0; this is done on line 6 of the program

Line 7 to 12 check if employee Ratings is 1, 2 or 3 and the respective bonusRate is used

Line 13 calculates the employee's bonus

Line 14 prints the employee's bonus

The program is ended on line 15

Ver imagen MrRoyal
ACCESS MORE