Answer to Question #290421 in Python for dv13

Question #290421

Create a class Emp with 3 instance variables named: emp_id, emp_name and pay. In this, emp_id and emp_name are the strings and pay data type is a float. This class also has a member function ‘total_salary()’ – this method will compute the total salary of employees.


The total salary should be sum of all allowances using:

  • Total_salary=(pay+house+hosp+bonus)-Insurance
  • House allowance is 10% of pay.
  • Medical allowance is 5% of pay.
  • bonus is 8% of pay.
  • insurance is 10% of pay


Sample Input:

Enter the employee id:1

Enter the employee name: Bob

Enter the pay:2000


Sample Output: 

Employee Id: 1 , Employee Name: Bob, Total Salary:2260.00



1
Expert's answer
2022-01-30T05:16:03-0500
class Emp:



    #initialize the attributes
    def __init__(self, name, id, pay):
        self.__name = name
        self.__id = id
        self.__pay = pay



    #set the attributes
    def set_name(self, name):
        self.__name = name



    def set_id(self, id):
        self.__id = id



    def set_pay(self, pay):
        self.__pay = pay



    #return the attributes
    def get_name(self):
        return self.__name



    def get_id(self):
        return self.__id



    def get_department(self):
        return self.__department



    #return the objects state as a string







    def total_salary(self):
        Total_salary = self.__pay + (0.1*self.__pay) + (0.05*self.__pay) + (0.08*self.__pay)-(0.1*self.__pay)
        return Total_salary

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