class Employee:
def __init__ (self, name, basic, house):
self.name = name
self.basic = basic
self.house = house
self.nhif = (2/100)* self.basic
self.tax = (30/100) * self.basic
def gross_income (self):
return (self.basic + self.house)
def total_deductions (self):
total_deductions = (self.nhif + self.tax)
return (self.total_deductions)
def net_salary (self):
net_salary = (self.gross_income - self.total_deductions)
return (self.net_salary)
employee1 = Employee ("Peter", 50000, 12000)
employee2 = Employee ("Mary", 60000, 15000)
employee3 = Employee ("Juma", 45000, 12000)
print ("Employee name:", employee1.name, "Gross pay: ", employee1.gross_income(), "Net_salary: ", employee1.net_salary)
print ("Employee name:", employee2.name, "Gross pay: ", employee2.gross_income(), "Net_salary: ", employee2.net_salary)
print ("Employee name:", employee3.name, "Gross pay: ", employee3.gross_income(), "Net_salary: ", employee3.net_salary)
OUTPUT
Employee name: Peter Gross pay: 62000 Net_salary: <bound method Employee.net_salary of <main.Employee object at 0x0000021AD3505D60>>
Employee name: Mary Gross pay: 75000 Net_salary: <bound method Employee.net_salary of <main.Employee object at 0x0000021AD35050D0>>
Employee name: Juma Gross pay: 57000 Net_salary: <bound method Employee.net_salary of <main.Employee object at 0x0000021AD33F8970>>