Code implemented in python
Note: Comments are written for this program
Filename: p5.py
Code:
from payroll import * import os import shutil employees = [] pay_log_file = "paylog.txt" def load_employees(): '''load all employees into memory''' with open("employees.csv", 'r') as f: data = [i.split(',') for i in f.read().split('\n')[1:]] for i in data[:-1]: emp = Employee(i[0], i[1], i[2], i[3], i[4], i[5]) if i[6] == str(2): emp.make_salaried(i[8]) elif i[6] == str(1): emp.make_hourly(i[9]) elif i[6] == str(3): emp.make_commissioned(i[8], i[10]) if (i[7] == str(1)): emp.direct_method(i[11], i[12]) elif (i[7] == str(2)): emp.mail_method() employees.append(emp) def find_employee_by_id(emp_id): '''return the emmployee with the correct id''' for i in employees: if i.emp_id == emp_id: return i def process_timecards(): '''load timecard data''' with open("timecards.txt", 'r') as f: timeCards = [i.split(',') for i in f.read().split('\n')] emp_id_list = [i[0] for i in timeCards] timeCards = [i[1:] for i in timeCards] timeDict = dict(zip(emp_id_list, timeCards)) for key, value in timeDict.items(): emp = find_employee_by_id(key) for i in value: emp.classification.add_timecard(i) def process_receipts(): '''load receipt data''' with open("receipts.txt", 'r') as f: r = [i.split(',') for i in f.read().split('\n')] emp_id_list = [i[0] for i in r] for i in emp_id_list[:-1]: emp = find_employee_by_id(i) for j in emp_id_list[1:]: emp.classification.add_receipt(i) def run_payroll(): '''execute main payroll logic''' if os.path.exists(pay_log_file): os.remove(pay_log_file) for emp in employees: emp.issue_payment() def main(): '''main priogram logig''' load_employees() process_timecards() process_receipts() run_payroll() # Save copy of payroll file; delete old file shutil.copyfile('paylog.txt', 'paylog_old.txt') if os.path.exists(pay_log_file): os.remove(pay_log_file) # Change Karina Gaay to Salaried and MailMethod by changing her Employee object: emp = find_employee_by_id('688997') emp.make_salaried(45884.99) emp.mail_method() emp.issue_payment() # Change TaShya Snow to Commissioned and DirectMethod; add some receipts emp = find_employee_by_id('522759') emp.make_commissioned(50005.50, 25) emp.direct_method('30417353-K', '465794-3611') clas = emp.classification clas.add_receipt(1109.73) clas.add_receipt(746.10) emp.issue_payment() # Change Rooney Alvarado to Hourly; add some hour entries emp = find_employee_by_id('165966') emp.make_hourly(21.53) clas = emp.classification clas.add_timecard(8.0) clas.add_timecard(8.0) clas.add_timecard(8.0) clas.add_timecard(8.0) clas.add_timecard(8.0) emp.issue_payment() if __name__ == '__main__': main()
Code Screenshots:
Working Code Output screenshots:
If you like my answer, hit thumbs up. Thank you.
in Python Project 5: Payroll (Part 1) CS 1410 Background In this project you will implement...
Write a Java application with a class name of Payroll, for the “Travel Agency”, that willCalculate the weekly paycheck for both Salaried and Hourly employees. Salaried employees will be paid 1/52 of their annual pay minus 18% withheld for federal and state taxes, as well as 4% for retirement pension. Salaried employees do not collect overtime pay. There are two types of Hourly employees; permanent employees and temporary weekly employees. •Permanent weekly employees will be paid their hourly rate minus...
java Payroll class Exceptions Programming Challenge 5 of Chapter 6 required you to write a Payroll class that calculates an employee’s payroll. Write exception classes for the following error conditions: • An empty string is given for the employee’s name. • An invalid value is given for the employee’s ID number. If you implemented this field as a string, then an empty string would be invalid. If you implemented this field as a numeric variable, then a negative number or...
Continuing Payroll Problem, 2B: Chapter 2 Olney Company, Inc. is a small manufacturing firm located in Newtown, Pennsylvania. The company has a workforce of both hourly and salaried employees. Each employee is paid for hours actually worked during each week, with the time worked being recorded in quarter-hour increments. The standard workweek consists of 40 hours, with all employees being paid time and one-half for any hours worked beyond the 40 regular hours. Wages are paid every Friday, with one...
Continuing Payroll Problem, 2B: Chapter 2 Olney Company, Inc. is a small manufacturing firm located in Allentown, Pennsylvania. The company has a workforce of both hourly and salaried employees. Each employee is paid for hours actually worked during each week, with the time worked being recorded in quarter-hour increments. The standard workweek consists of 40 hours, with all employees being paid time and one-half for any hours worked beyond the 40 regular hours. Wages are paid every Friday, with one...
Can you please show how you found the last 5 columns of the first spreadsheet. thank you. Stark Company has five employees. Employees paid by the hour earn $11 per hour for the regular 40-hour workweek and $16 per hour beyond the 40 hours per week. Hourly employees are paid every two weeks, but salaried employees are paid monthly on the last biweekly payday of each month. FICA Social Security taxes are 6.2% of the first $128.400 paid to each...
Python In this assignment you are asked to enhance the #3 to define a class to model the characteristics of a generic employee. The class is part of a slightly larger program that incl create some employee objects and test its methods. The name of the class is Employee' and includes the following methods and attributes: n program created in Lab udes code to use the class to Method Name Input/ Attributes Output/ Returns Purpose Constructor sets initial values See...
0.Use Factory Design Method 1. Implement an interface called EmployeeInfo with the following constant variables: FACULTY_MONTHLY_SALARY = 6000.00 STAFF_MONTHLY_HOURS_WORKED = 160 2. Implement an abstract class Employee with the following requirements: Attributes last name (String) first name (String) ID number (String) Sex - M or F Birth date - Use the Calendar Java class to create a date object Default argument constructor and argument constructors. Public methods toString - returning a string with the following format: ID Employee number :_________...
Continuing Payroll Problem, 2A: Chapter 2 Kipley Company is a small manufacturing firm located in Pittsburgh, Pennsylvania. The company has a workforce of both hourly and salaried employees. Each employee is paid for hours actually worked during each week, with the time worked being recorded in quarter-hour increments. The standard workweek consists of 40 hours, with all employees being paid time and one-half for any hours worked beyond the 40 regular hours. Wages are paid every Friday, with one week's...