Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

App Inventor

Authors: David Wolber, Hal Abelson

1st Edition

1449397484, 9781449397487

More Books

Students also viewed these Programming questions

Question

Find the inverse, if it exists, for the matrix. -1

Answered: 1 week ago