Professional Documents
Culture Documents
Create a class EmployeePayroll that has the following attributes and methods (see Table 1). You
will use this class
to calculate the employee’s monthly gross income and other necessary details.
from the monthly basic salary. The total contributions include the sum of GSIS,
monthly basic salary. PHILHEALTH, PAG-IBIG and withholding tax are computed
based on the tables 2, 3, and 4 below.
Compute the age based on the employee’s birthday given in this format
“mm/dd/yyyy”. The method promote updates the position and the basic salary of the employee
by including two parameters: the new position and the new basic salary of the
employee.
EmployeePayroll
attribute
birthday: str
gender: str
method
get_age()
get_gsis_contrib()
get_philhealth_contrib()
get_pagibig_contrib()
get_wtax()
get_total_deductions()
get_gross_income()
promote()
After instantiating the objects (on Table 5), display the payroll table (as shown on Table 6).
Display a menu to the user to choose the action he wants to do, such as, but not limited to, View
Payroll, View Employee details,
Promote Employee, Update name, Update civil status. Have a loop to keep the program running
until the user exits.
import datetime
class EmployeePayroll:
def __init__(self, first_name, last_name, birthday, gender, civil_status, position, basic_salary):
self.first_name = first_name
self.last_name = last_name
self.gender = gender
self.civil_status = civil_status
self.position = position
self.basic_salary = basic_salary
def get_age(self):
today = datetime.date.today()
print(f"Age: {age}")
def get_gsis_contrib(self):
def get_philhealth_contrib(self):
philhealth_contrib = 200
else:
philhealth_contrib = 1600
else:
def get_wtax(self):
if self.basic_salary <= 20833:
wtax = 0
else:
def get_total_deductions(self):
self.position = new_position
self.basic_salary = new_basic_salary
employees = [
def display_payroll():
emp.get_gsis_contrib()
emp.get_philhealth_contrib()
emp.get_pagibig_contrib()
emp.get_wtax()
emp.get_gross_income()
def display_employee_details():
emp.get_age()
def promote_employee():
emp.promote(new_position, new_basic_salary)
return
def update_name():
emp.first_name = new_first_name
emp.last_name = new_last_name
return
def update_civil_status():
first_name = input("Enter employee's first name: ")
emp.civil_status = new_civil_status
return
while True:
if choice == "1":
display_payroll()
display_employee_details()
elif choice == "3":
promote_employee()
update_name()
update_civil_status()
print("Exiting...")
break
else:
class EmployeePayroll:
self.first_name = first_name
self.last_name = last_name
self.gender = gender
self.civil_status = civil_status
self.position = position
self.basic_salary = basic_salary
def get_age(self):
today = datetime.date.today()
print(f"Age: {age}")
def get_gsis_contrib(self):
return gsis_contrib
def get_philhealth_contrib(self):
philhealth_contrib = 200
philhealth_contrib = 1600
return philhealth_contrib
def get_pagibig_contrib(self):
else:
def get_wtax(self):
wtax = 0
else:
return wtax
def get_total_deductions(self):
total_deductions = self.get_gsis_contrib() + self.get_philhealth_contrib() +
self.get_pagibig_contrib() + self.get_wtax()
return total_deductions
def get_gross_income(self):
return gross_income
self.basic_salary = new_basic_salary
employees = [
def display_payroll():
gsis = emp.get_gsis_contrib()
philhealth = emp.get_philhealth_contrib()
pagibig = emp.get_pagibig_contrib()
wtax = emp.get_wtax()
gross_income = emp.get_gross_income()
print(f"{gsis:.2f}\t{philhealth:.2f}\t{pagibig:.2f}\t{wtax:.2f}\t{gross_income:.2f}")
def display_employee_details():
emp.get_age()
def promote_employee():
emp.promote(new_position, new_basic_salary)
return
def update_name():
first_name = input("Enter employee's first name: ")
emp.first_name = new_first_name
emp.last_name = new_last_name
def update_civil_status():
emp.civil_status = new_civil_status
return
while True:
display_payroll()
display_employee_details()
promote_employee()
update_name()
print("Exiting...")
break
else: