Answer to Question #313417 in Python for dv13

Question #313417

write this python code using data Classes 

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.


5. Create a class BasePlusCommissionEmployee 

a. BasePlusCommissionEmployee class is a child class of CommissionEmployee. It should inherit

all the attributes of CommissionEmployee class and add its own attribute baseSalary.

b. Create a method called calculateTotalEarning which should inherit super class method

calculateCommission and add baseSalary in it.


1
Expert's answer
2022-03-18T12:13:50-0400
from email.mime import base



class Employee:
    def __init__(self, fName, lName, age, address, cntNumber, id,
                 orgName, pos):
        self.firstName = fName
        self.lastName = lName
        self.age = age
        self.address = address
        self.contactNumbe = cntNumber
        self.ID = id
        self.organizationName = orgName
        self.position = pos



class SalaryEmployee(Employee):
    def __init__(self, fName, lName, age, address, cntNumber, id,
                 orgName, pos, baseSalary):
        super.__init__(fName, lName, age, address, cntNumber, id,
                 orgName, pos)
        self.baseSalary = baseSalary
           
    def CalculateNetSalary(self):
        provTax = 0.13 * self.baseSalary
        insurance = 0.01 * self.baseSalary
        fedTax = 0.03 * self.baseSalary
        netSalary = self.baseSalary - provTax - insurance - fedTax
        return netSalary


    def DisplayData(self):
        print('First name:', self.firstName)
        print('Last name:', self.lastName)
        print('Age:', self.age)
        print('Address:', self.address)
        print('Contact number:', self.contactNumbe)
        print('Employee ID:', self.ID)
        print('Organization name:', self.organizationName)
        print('Position:', self.position)
        netSalary = self.CalculateNetSalary()
        print(f'Net salary: ${netSalary:.2f}')


class CommissionEmployee(Employee):
    def __init__(self, fName, lName, age, address, cntNumber, id,
                 orgName, pos, commision):
        super.__init__(fName, lName, age, address, cntNumber, id,
                 orgName, pos)
        self.commision = commision


    def CalculateCommision(self, income):
        return income * self.commision


class BasePlusCommissionEmployee(CommissionEmployee):
    def __init__(self, fName, lName, age, address, cntNumber, id,
                 orgName, pos, commision, base):
        super.__init__(fName, lName, age, address, cntNumber, id,
                 orgName, pos, commision)
        self.baseSalary = base


    def CalculateTotalEarning(self, income):
        return self.CalculateCommision(income) + self.baseSalary

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS