127k views
5 votes
Create a program to manage payroll for Saddleback College Employees. There are 3 types of employees: Salary

(include full-time Faculty), Part-time Faculty, and Hourly. Use inheritance and method overriding from chapter 13.
Create a base employee which holds the employees' first and last name, and their 5-digit ID number. Salary
employees are paid a monthly salary. Part-time faculty are paid a set amount (say $1000) for each credit unit they
teach. Hourly employees are paid based on the number of hours worked multiplied by their hourly rate. Once the
program starts it should load the payroll database file (payroll.txt) and welcome the user. Then the program should
allow the user the options to (1) list all employees, (2) add a new employee, (3) remove an existing employee, (4)
display info on an existing employee, (5) calculate and display the monthly pay for all employees, and (6) save the
payroll database file. Below are some example screenshots to help you create your program.
Menu
Welcome to the Saddleback College Employee Payroll System.
Menu:
(1) List All Employees
(2) Add a New Employee
(3) Remove an Existing Employee
(4) Display Info on an Employee
(5) Calculate Monthly Payroll
(6) Save Database
(7) Exit
Choose an option:
List All Employees
Choose an option: 1
Listing All Employees...
I.D. #
12345
12221
13332
14563
17894
First Name
h - Hourly
p
John
Andrew
Abraham
John
Ronald
Add a New Employee (Full-Time):
Choose an option: 2
Adding a New Employee...
Enter First Name: George
Enter Last Name: Washington
Enter Employee 5-Digit I.D.#: 56789
Enter their job type:
f - Full-Time
f
h - Hourly
Part-Time Faculty
Choose an option: f
Enter their monthly salary: 15000.00
Successfully added George Washington
Add a New Employee (Part-Time Faculty):
Choose an option: 2
Adding a New Employee...
Enter First Name: Thomas
Enter Last Name: Jefferson
Enter Employee 5-Digit I.D.#: 56792
Enter their job type:
Full-Time
p - Part-Time Faculty
Choose an option: h
Last Name
Adams
Jackson
Lincoln
Kennedy
Reagan
Add a New Employee (Hourly):
Choose an option: 2
Adding a New Employee...
Enter First Name: Jimmy
Enter Last Name: Carter
Part-Time Faculty
Enter Employee 5-Digit I.D.#: 56795
Enter their job type:
f - Full-Time
h - Hourly
p
Enter their hourly rate: 100.00
Enter the number of hours they worked (in 1 month): 175.00
Successfully added Thomas Jefferson
Choose an option: p
Enter the number of units they teach: 4.0
Successfully added Jimmy Carter
Choose an option: 3
Removing an Employee...
Remove an Existing Employee
Display Info on an Employee
Enter First Name: Andrew
Enter Last Name: Jackson
Enter Employee 5-Digit I.D.#: 12221
Successfully removed Andrew Jackson
Employee found:
Choose an option: 4
Displaying Info on an Employee...
Enter First Name: Abraham
Enter Last Name: Lincoln
Abraham Lincoln - I.D.# 13332
Employee Type: PT Faculty
Calculate Monthly Payroll
Choose an option: 5
Calculating Monthly Payroll...
John Adams - I.D.# 12345
Employee Type: Full-Time
Check Amount: $9999.99
John Kennedy - I.D.# 14563
Employee Type: Full-Time
Check Amount: $8753.59
Abraham Lincoln - I.D.# 13332
Employee Type: PT Faculty
Check Amount: $3000.00
Ronald Reagan - I.D.# 17894
Employee Type: Full-Time
Check Amount: $11231.45
George Washington - I.D. # 56789
Employee Type: Full-Time
Check Amount: $15000.00
Jimmy Carter - I.D.# 56795
Employee Type: PT Faculty
Check Amount: $4000.00
Thomas Jefferson - I.D.# 56792
Employee Type: Hourly
Check Amount: $17500.00
Employee Type
Save Database
Choose an option: 6
SUCCESS! payroll.txt is saved.
Full-Time
Hourly
PT Faculty
Full-Time
Full-Time

User OregonJeff
by
8.3k points

1 Answer

6 votes

Answer:

class Employee:

def __init__(self, first_name, last_name, id_number):

self.first_name = first_name

self.last_name = last_name

self.id_number = id_number

def calculate_payroll(self):

pass

class SalaryEmployee(Employee):

def __init__(self, first_name, last_name, id_number, monthly_salary):

super().__init__(first_name, last_name, id_number)

self.monthly_salary = monthly_salary

def calculate_payroll(self):

return self.monthly_salary

class PartTimeFaculty(Employee):

def __init__(self, first_name, last_name, id_number, credit_units):

super().__init__(first_name, last_name, id_number)

self.credit_units = credit_units

def calculate_payroll(self):

return self.credit_units * 1000

class HourlyEmployee(Employee):

def __init__(self, first_name, last_name, id_number, hourly_rate, hours_worked):

super().__init__(first_name, last_name, id_number)

self.hourly_rate = hourly_rate

self.hours_worked = hours_worked

def calculate_payroll(self):

return self.hourly_rate * self.hours_worked

def main():

employees = [] # List to hold employee objects

# Load payroll database from file (payroll.txt)

while True:

print("Welcome to the Saddleback College Employee Payroll System.")

print("Menu:")

print("(1) List All Employees")

print("(2) Add a New Employee")

print("(3) Remove an Existing Employee")

print("(4) Display Info on an Employee")

print("(5) Calculate Monthly Payroll")

print("(6) Save Database")

print("(7) Exit")

choice = int(input("Choose an option: "))

if choice == 1:

# List all employees

pass

elif choice == 2:

# Add a new employee

pass

elif choice == 3:

# Remove an existing employee

pass

elif choice == 4:

# Display info on an employee

pass

elif choice == 5:

# Calculate monthly payroll

pass

elif choice == 6:

# Save database to file (payroll.txt)

pass

elif choice == 7:

# Exit the program

break

else:

print("Invalid choice. Please select a valid option.")

if __name__ == "__main__":

main()

User Hamid Parchami
by
8.1k points