Question: In this program you will once again be developing a solution to solve a described problem. Many of the skills you called upon to finish

In this program you will once again be developing a solution to solve a described problem. Many of the skills you called upon to finish previous work will be needed in addition to new skills such as:

  • string manipulation
  • list structures and related commands
  • string formatting
  • string methods

Project Overview

In this project, we are again doing payroll processing. You will see some similarities to project 1; however, you will be coding a solution that is more comprehensive in nature, including being able to process two different types of input.

Information to be Provided

Typically data is maintained in stored data files. However, because we have not yet covered processing of input from files in Python, we will instead be providing some of the information needed for this project via predefined lists. These lists are provided as part of the starting code for the project.

The employee information is provided in the following synchronized lists:

  • Employee Number
  • Employee Name
  • Employee Address 1 (street address)
  • Employee Address 2 (city, state zipcode)
  • Employee Marital Status
  • Employee Hourly Pay Rate
  • Employee 401(k) deduction percentage

Clarification: when we refer to synchronized lists, we mean that each list is aligned with its corresponding information. This means, for example, that the fifth item in each of the employee lists pertain to the same employee.

Processing - Overview

Your program will need to be able to process two different types of payroll processing requests:

  1. Address change request.
    • Check to see if new address in input contains a valid zipcode.
    • Display error message for invalid data, or update the employee address.
  2. Payroll calculation request.
    • Calculate pay from time card(s)
    • Calculate deductions
    • Generate formatted paycheck report

These requests will be provided through user input instructions that you will have to specify in your program. More details on each request is provided below.

Because we have not covered iteration yet, your program will process only one request at a time. Your program must be able to process either of the request types based on the data that is provided as input. For each run of the program, you will prompt the user for input and they will enter information for one of the above payroll processing requests. When you run the program in submit mode, zyBooks will simulate running the program multiple times providing a single processing request to your program to process for each "run".

IMPORTANT NOTE ! While you will still be allowed unlimited attempts and runs in Develop mode, your number of submissions in Submit Mode will be restricted to 50, and there is a waiting time of 5 minutes between Submit Mode submissions. This is intended to help you make better use of your time and understanding of your program, instead of employing a random guess and submit strategy which does not help you. Remember, you can submit as many times as you want in develop mode with no restrictions.

Processing - Details

Address Change Request Format

An Address Change Request will be provided as a single input line to your program.

The Address Change Request will consist of:

  • A three-character request type (ACR),
  • A five-digit employee number,
  • A 30-character address representing the employee's new street address, and
  • A 30-character address representing the employee's new city/state/zip.

Example Address Change Request:

ACR50991322 Maple Street Dewitt, MI 48820-9876 

Data in an address change request is in fixed width format. Different data elements will always fall in the same location in the data line. In other words, it is guaranteed that the first 3 characters are the request type (ACR), the next 5 characters are the employee number, the next 30 are the street address, and the next 30 are the city, state, and zip. Note that while the address fields in the input line are 30 characters each to allow for potentially long addresses, the addresses in the Employee lists are variable length and do not have the trailing spaces.

Payroll Calculate Request Format

A Payroll Calculation Request as input will start with the characters PCR, and it means that you will have to read one additional input line to complete the request.

Each Payroll Calculation Request will always consist of two lines.

The format of the first line of a Payroll Calculation Request is in fixed width format and will consist of:

  • A three-character request type (PCR)
  • A five-digit employee number
  • An eight-digit payroll date (MMDDYYYY)

The second line of the Payroll Calculation Request input data is in delimited format and will consist of:

  • A variable length number of digits representing hours worked in the week (e.g., 5, 10.75, 55.5, etc.),
  • A variable length premium percentage % (0%, 5.5%, 25%, 100%, etc.),
  • An eight-digit date (MMDDYYYY) indicating the work date for this timecard

Premium percentage is an indicator that during this pay period, the employee will get an addition to their regular rate for reasons like hazardous work, night shift, etc.

Note there is a hashtag (#) between each data element in the input.

Example 1 Payroll Calculation Request input:

PCR5099105212020 55#0%#05142020 

Example 2 Payroll Calculation Request input:

PCR5099105212020 5.75#25%#05152020 

The second example shows that the employee is receiving a 25% premium on 5.75 hours of work.

Processing - Detailed

General

Your program will need to perform the necessary input statements to retrieve request data from the user. This will include inputting the first line of data, which you can use to direct your subsequent processing which, depending on request type, may require additional input operations. Due to the nature of this problem, you would not normally include any user prompt text as part of your input instructions, but you can use input prompts as you wish to keep things straight. Reminder: your program is only processing one type of request (either ACR or PCR) for each run of the program, but it needs to be able to handle both kinds.

Processing specific to the type of request you are working with is discussed below.

Error checking - general

After getting the first line of data for a request, your program should perform general error checking. Required validation and associated error messages include:

  • Check first to see if the request type is valid. (Is it ACR or PCR?). If it is neither of these types, then you should display the following error and perform no further processing:
Invalid request type (XXX) 

where XXX was the request type that was input.

  • Checking for a valid employee number (does the employee number exist in the employee list data?). If it does not exist, you should display the following error and perform no further processing:
Invalid employee number (#####) 

where ##### is what was in the employee number position

If no error conditions exist at this point, you should proceed with the appropriate processing of the request you have read in.

Specific Processing

Employee Address Change

If the request is an employee address change, you will need to perform the following processing:

  1. Error checking:
    • Check to see if the new address contains a valid zipcode according to the following rules:
      • 10 characters in length
      • 5 numeric digits, followed by a hyphen (dash), followed by 4 numeric characters.
    • If the zipcode does not meet this validity check, display the following message and perform no further processing:
 Invalid zipcode, request denied 
  1. Valid data process employee address change:
    • Update the employee address line 1 with the new street address in the employee data,
    • Update the employee address line 2 with the new city, state, and zip in the employee data, and
    • Print the entire employee_address line 1 list
    • Print the entire employee_address line 2 list (just print the entire list in both cases - no special formatting required)

Payroll calculation request

  • Additional input

    • If the first line of data you read is a payroll calculation request, you will have to take in another row of data
  • Pay Calculation

    • For the additional row of input, you need to calculate the pay associated with the time card. Gross pay is a combination of regular pay and premium pay which is given for performing hazardous work. Gross pay should be calculated with the following considerations:
      • Time card pay is regular pay + premium pay (if applicable)
      • Regular pay is employee standard pay rate x hours worked on the time card
      • Premium pay is regular pay x premium % from the time card
  • Deductions Calculation

    • After computing the gross pay, you need to calculate the following deductions:
      • Federal Tax
      • Health Insurance Deduction, and
      • 401(k) Deduction
    • The Federal Tax Deduction will be essentially the same calculations you performed in project 1. However, we have created a function called federal_tax to perform this function for you. This function is included in the starting code for the project. To use this function, you must pass the annual income and the marital status as arguments; as a result, the function will return the an unrounded annual tax amount.Do not change any of the code in this function. Recall that in project 1 we used an annual income to compute federal tax. In this project, we are calculating a weekly pay -- you will need to take this into account when calling the federal_tax function and when using the result from the function.
    • The Health Insurance deduction will also be essentially the same as project 1. You may write a function to compute the Health Insurance deduction if you wish, but it is not required. As a reminder, the annual health insurance deduction for single employees is $800, while the deduction for married employees is $1000.
    • Finally, the 401(k) deduction will be calculated by finding the employee's 401(k) deduction percentage in the employee tables, then multiplying the deduction percentage times the gross pay for the employee. This should represent a weekly deduction.

Note: we are not concerned with rounding at the calculation level, however, please take note of the decimal precision represented in the output below.

  • Output

    • Once you have calculated the necessary information, you should generate a pay summary for the employee. Given the following input:
PCR9906601022021 13.3#0%#12232020 

you should generate an output looking like the following:

One-Oh-2 Company Date: 01/02/2021 99066 / McGee, Fibber 79 Wistful Vista Des Moines, IA 50310-5565 PAY CALCULATION Workdate Hours Premium Rate Gross Pay Deductions Netpay 12/23/2020 13.30 0% 71.45 950.29 DEDUCTIONS Federal Healthcare 401K 89.20 15.38 199.56 NET PAY $ 950.29 $ 304.15 $ 646.14

how would we do the PCR request

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!