4. Create a class SalariedEmployee
a. SalariedEmployee class is a child class of Employee class. It should inherit all the attributes of
Employee class and add its own attribute baseSalary.
b. Create a method called CalculateNetSalary which should deduct 13% Provisional Tax, 1%
insurance and 3% Fed Tax from baseSalary and display the NetSalary.
c. Create a method called displayData which should display the FirstName, LastName, Age,
Address, ContactNumber, EmployeeID, OrganizationName, Position, baseSalary and
NetSalary.
class Employee:
FirstName = ''
LastName = ''
Age = 0
Address = ''
ContactNumber = ''
EmployeeID = ''
OrganizationName = ''
Pozition = ''
class SalariedEmployee(Employee):
baseSalary = 0
def CalculateNetSalary(self):
self.NetSolary = self.baseSalary * (100 - 13 - 1 - 3)/100
print('NetSolary = ', self.NetSolary)
def displayData(self):
print( f'FirstName: {self.FirstName}',
f'LastName: {self.LastName}',
f'Age: {self.Age}',
f'Address: {self.Address}',
f'ContactNumber: {self.ContactNumber}',
f'EmployeeID: {self.EmployeeID}',
f'OrganizationName: {self.OrganizationName}',
f'Pozition: {self.Pozition}',
f'baseSolary: {self.baseSalary}',
f'NetSolary: {self.NetSolary}',
sep='\n')
Tom = SalariedEmployee()
Tom.FirstName = 'Tom'
Tom.LastName = 'Cruse'
Tom.baseSalary = 5000
Tom.Age = 25
Tom.Address = 'Paris'
Tom.ContactNumber = '123945687'
Tom.EmployeeID = '4561987534562315'
Tom.OrganizationName = 'Bosch'
Tom.Pozition = 'Full Stack Engineer'
Tom.CalculateNetSalary()
Tom.displayData()
Comments
Leave a comment