this is also a question part
1 - 'getInfo()' which takes the salary, number of hours of work per day of employee as parameter
2 - 'AddSal()' which adds 10 to salary of the employee if it is less than 500.
3 - 'AddWork()' which adds 5 to salary of employee if the number of hours of work per day is more than 6 hours.
Hello Everyone 👋
You must be seeing the above question. So here we discuss the problem
There is some few step which we hove do it-
First we will create a Employee class
Create a 3 methods which is mention the about question
. First method getInfo()
. Second method AddSal()
. third method AddWork()
- here we create one more method that is final salary() which give use the employee salary
Here is the Ans of this Problem
class Employee:
def __init__(self,name):
self.name=name
def getInfo(self,salary,hours):
self.salary=salary
self.hours=hours
def AddSal(self):
if self.salary<500:
self.salary+=10
return self.salary
def AddWork(self):
if self.hours>6:
self.salary+=5
return self.salary
def print_final_salary(self):
print(self.name,self.salary)
name=str(input("enter name:"))
salary=int(input("Enter Salary:"))
hours=float(input("enter hours:"))
emp=Employee(name)
emp.getInfo(salary,hours)
emp.AddSal()
emp.AddWork()
emp.print_final_salary()
I hope you like will help you for your DSA interview preparation
Thank You
Shivani Tiwari
Top comments (0)