Python program by creating a class called Employee to store the details

7.B] Write a python program by creating a class called Employee to store the details of Name,
Employee_ID, Department and Salary, and implement a method to update salary of
employees belonging to a given department.

class Employee:
    def __init__(self):
        self.name=""
        self.empId=""
        self.dept=""
        self.salary=""

    def getEmpDetails(self):
        self.name=input("Enter the emp name: ")
        self.empId=input("Enter emp id: ")
        self.dept=input("Enter Dept: ")
        self.salary=input("Enter Salary")

    def showEmpDetails(self):
        print("Emp Details")
        print("Name: ",self.name)
        print("Empid: ",self.empId)
        print("Dept: ",self.dept)

    def updtSalary(self):
        self.updtSalary=int(input("Enter new salary: "))
        print("Updated salary", self.updtSalary)

e1=Employee()
e1.getEmpDetails()
e1.showEmpDetails()
e1.updtSalary()

Leave a Reply

Your email address will not be published. Required fields are marked *