Advertisements
Advertisements
प्रश्न
Pay roll information system:
→ Declare the base class 'employee' with employee's number, name, designation, address, phone number.
→ Define and declare the function getdata() and putdata() to get the employee's details and print employee's details.
→ Declare the derived class salary with basic pay, DA, HRA, Gross pay, PF, Income tax and Net pay.
→ Declare and define the function getdata1() to call getdata() and get the basic pay,
→ Define the function calculate() to find the net pay
→ Define the function display() to call putdata() and display salary details .
→ Create the derived class object.
→ Read the number of employees.
→ Call the function getdata1() and calculate() to each employees.
→ Call the display() function.
Advertisements
उत्तर
class Employee(object):
def getdata(self):
self.number = input("Employee number: ")
self.name = input("Name: ")
self.designation = input("Designation: ")
self.address = input("Address: ")
self.phone = input("Phone number: ")
def putdata(self):
print("\nEmployee number:", self.number)
print("Name:", self.name)
print("Designation:", self.designation)
print("Address:", self.address)
print("Phone:", self.phone)
class Salary(Employee):
def getdata1(self):
self.getdata()
self.basic_pay = float(input("Basic pay: "))
def calculate(self):
self.da = self.basic_pay * 0.20
self.hra = self.basic_pay * 0.10
self.gross_pay = self.basic_pay + self.da + self.hra
self.pf = self.basic_pay * 0.12
self.income_tax = self.gross_pay * 0.05
self.net_pay = self.gross_pay - self.pf - self.income_tax
def display(self):
self.putdata()
print("Basic pay:", self.basic_pay)
print("DA:", self.da)
print("HRA:", self.hra)
print("Gross pay:", self.gross_pay)
print("PF:", self.pf)
print("Income tax:", self.income_tax)
print("Net pay:", self.net_pay)
n = int(input("Enter number of employees: "))
for i in range(n):
print("\nEmployee", i + 1)
emp = Salary()
emp.getdata1()
emp.calculate()
emp.display()
The percentage rates used in calculate() may be changed according to the organisation's rules.
