Question: Python Task: Define first classes PayrollSystem, having method calculate_payroll and getting a list of employees as a parameter. Method should calculate and print payroll for

Python

Task:

Define first classes

  1. PayrollSystem, having method calculate_payroll and getting a list of employees as a parameter. Method should calculate and print payroll for employees.
  2. SalaryEmployee, a subclass of Employee. SalaryEmployee has its own attribute monthly_salary and method calculate_salary, which will return the monthly salary of an employee.

Finally make then program,

  • asking employee name as in previous Employee-exercise and also asking monthly salary for SalaryEmployee-class.
  • creating SalaryEmployee-objects and store them into a list.
  • ending when user gives '0' instead of a name.
  • using at the end PayrollSystem to print Payroll for Employees in a format shown in the example below.

Example output:

Please enter employee name (0 to quit):Jane Doe Please enter salary:5500 Please enter employee name (0 to quit):John Johnson Please enter salary:4500 Please enter employee name (0 to quit):Richard Roe Please enter salary:5050 Please enter employee name (0 to quit):0 Employee Payroll ================ Payroll for: 1 - Jane Doe - Check amount: 5500

Employee Payroll ================ Payroll for: 2 - John Johnson - Check amount: 4500

Employee Payroll ================ Payroll for: 3 - Richard Roe - Check amount: 5050

Edit: This should be the Employee class task ( noother task about Employee class has not been given ):

#Employee Class class Employee: #init method def __init__(self,id,name): self.id=id self.name=name #id Counter id1=0 #list for storing Objects l=[] #True method while(True): name=input("Please enter employee name(0 to quit):") if(name=="0"): break id1+=1 #appending object to the list and calling Employee class l.append(Employee(id1,name)) #print the value of objects for i in range(0,len(l)): print("Id: %d Name:%s"%(l[i].id,l[i].name))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!