Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CIS 221 PA5 - Ch6 & Ch13 Employee Payroll Summary: PYTHON 3 CODE CORRECT INDENTATION WITH ALL VARIABLES DECLARED WINDOWS For this assignment, you will

CIS 221 PA5 - Ch6 & Ch13

Employee Payroll Summary: PYTHON 3 CODE CORRECT INDENTATION WITH ALL VARIABLES DECLARED WINDOWS

For this assignment, you will write a program that reads employee work data from a text file, and then calculates payroll information based on this file. The text file contains one line of text for each employee. Each line consists of the following data (delimited by tabs):

employees name

employees hourly wage rate

hours worked Monday

hours worked Tuesday

hours worked Wednesday

hours worked Thursday

hours worked Friday

The employee Smith makes $10 per hour, and worked 8 hours on Monday, 8 on Tuesday, 8 on Wednesday, 8 on Thursday, and 10 on Friday. You can see similar data for the other employees.

Smith 10 8 8 8 8 10

Jones 12.50 4 7 5 3.3 2.2

Miller 20 6.5 9 1 1 1

Baker 15 7.5 9 4 0 2

Ahmad 11.50 4.5 9 7 3 2

Choi 6.50 20 20 2.5 4 4

Link to text file: http://www.filedropper.com/empwages

Link to instructions and screenshots: http://www.filedropper.com/pa5instructions

Expected Behavior of your Program

The following screen shots illustrate what your program should be able to do:

The program will repeatedly present a menu of options, as shown below.

These are the only allowable options. If the user types anything other than r, p, d, h, l, or q, you should print an error message, and again present the menu, like this:

Assume the user selects to read a file. Your program will ask the user for the file name (it must be in the same folder as your .py file), attempt to read this file, and use it to populate three lists: a list containing each employees name, a list of each employees hourly wage, and a list containing each employees total hours worked for the week.

When this is completed, these lists should be sorted in order based on the employee names (more about this later). Assuming the file was successfully read, and data successfully input, you should present a confirmation message, like this, followed again by the menu.

If the above file was read successfully into the three lists, they will look like this in memory:

Note: its possible that the user could enter an invalid file name. In this case an error message should appear, like this:

Even if the file does exist, you may still have problems processing the data. For example, if the hours worked or the hourly wages are missing or non-numeric, this is an error. In this case, you should also print out an error message, like in this display:

Once the file is successfully read and processed, the user can select the other menu options. The following screen shots show the payroll report, a display of a selected employee (based on name), the highest paid employee, and the lowest paid employee:

Note: none of these options should be allowed if no data has been loaded into the lists. If the lists are empty, and the user enters one of these options, you should display an error message and again present the menu, as shown below:

Finally, when the user wants to quit, print a goodbye message and terminate the program:

Program Design Specifications

The structure chart showing the top-down stepwise refinement for your program is shown below.

You will define each of the above functions. The main function will call each of the functions underneath it, and the display & find functions will in turn call linear search. The behaviors of each of these functions are described below:

main will loop continuously, calling the menu function and using the returned choice to determine which other function to call, until the user decides to quit.

menu will loop continuously, presenting the menu and inputting the users response, until the user enters a valid choice. Every time the user enters an incorrect choice, it will display an error message as shown above. Once the user enters a valid choice, the menu function will return that value.

read employees will take in the file name as an argument. It will open the desired file, and use exception handling to deal with non-existent file or file with bad data. It will read all lines into a list, and sort that list alphabetically. Then it will use this list to populate the employee names list, the hourly wage list, and the hours worked list. Note that the values in the hours worked list will be a sum of all the hours for the week (M, T, W, TH, F).

print payroll will display the payroll report as shown above. This includes a header, the list of each employee with hours worked for the week and total pay for the week.

display by name will receive an argument from main, use the linear search to find the index of that employee, and use this to display the name, hours worked, hourly wage, and total pay for the week, as shown above. The function should be flexible enough to recognize the employee name even if it is not capitalized. If the employee is not found, a message should be printed to that effect.

Find high/low paid employee will receive an argument from main (either h or l, i.e. the users choice). It will use this to find the maximum (or minimum) total pay for the week, and then do a linear search to find the employee with that total pay. Then it will display the employees name and earnings for that employee, as shown above. Note: we are looking for maximum or minimum total earnings, not max/min hourly wage.

Additional requirements:

The menu function can input data from the user (the user choice). This is the only function other than main that can input from user. All other functions must receive user inputs as arguments passed in. No function other than menu and main can call Pythons input() function.

The three lists (employee names, employee hourly wage rates, and employee hours worked) will all be global variables. All other variables in your program must be local variables of functions.

Your program must be fully documented with appropriate comments. There should be a comment for each function describing what it does. In addition, you should briefly describe different sections of code within each function.

Do not hard code the file name empwages.txt; your program should work with any file that is properly formatted regardless of the number of employees. For example, if I name a file stuff.txt, place it in the same folder as your program and it is correctly formatted, then your program should open that file successfully.

Hint: tackle these functions one at a time. Make sure menu works before trying read. Make sure read works before trying to print payroll, etc.

Deliverables:

You will turn in your .py file and your planning doc (pseudocode or flowchart). Zip these files into a .zip file and upload that single .zip file to Canvas.

You dont have to upload the empwages.txt file.image text in transcribed

Once the file is successfully read and processed, the user can select the other menu options. The following screen shots show the payroll report, a display of a selected employee (based on name), the highest paid employee, and the lowest paid employee Please enter your choice: p Name Hours Pay 25.5 50.5 S293.25 S337. 50 $328.25 $269.7S $370.00 S420.00 Ahmad Baker 22.S Choi ones 21.S Miller 18.5 Smith 42 Total payroll = $2017.75 Please enter your choice: d Enter the employee's name: choi Choi worked 50.5 hours a $ 6.50 per hour, and earned $328.25 Pleds enter you! choice: h Smith earned $420.00 Please enter your choice: 1 Jones earned $263.75 Note: none of these options should be allowed ifno data has been loaded into the lists. If the lists are empty, and the user enters one of these options, you should display an error message and again present the menu, as shown below: Please enter your choice: p Employee data ha not been read Please read the file befoe making this choice Menu of choices (r)ead employee data (p)rint employee payroll (d) isplay an employee by name find (h) ighest paid employee find (1) owest paid employee g)uit Please enter ur choice: Finally, when the user wants to quit, print a goodbye messagc and terminate the program Please enter your choice: Goodbye

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Evaluating Group Performance?

Answered: 1 week ago