Question

The Payroll Department keeps a list of employee information for each pay period in a text...

The Payroll Department keeps a list of employee information for each pay period in a text file. The format of each line of the file is the following: Write a program that inputs a filename from the user and prints to the terminal a report of the wages paid to the employees for the given period. The report should be in tabular format with the appropriate header. Each line should contain: An employee’s name The hours worked The wages paid for that period.

An example of the program input and output is shown below:

Enter the file name: data.txt Name Hours Total Pay Lambert 34 357.00 Osborne 22 137.50 Giacometti 5 503.50

It has this information in the data.txt page and I need any additional information for this page and the payroll.py page.

Lambert 34 10.50
Osborne 22 6.25
Giacometti 5 100.70

We are using the newest form of python which I believe is 3.

0 0
Add a comment Improve this question Transcribed image text
✔ Recommended Answer
Answer #1

If you have any doubts, please give me comment...

Code:

fname = input("Enter the file name: ")

fp = open(fname, "r")

print("Name Hours Total Pay")

for line in fp.readlines():

cols = line.strip().split()

print("%s %d %.2f"%(cols[0],int(cols[1]),int(cols[1])*float(cols[2])))

fp.close()

Add a comment
Know the answer?
Add Answer to:
The Payroll Department keeps a list of employee information for each pay period in a text...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • The Payroll Department keeps a list of employee information for each pay period in a text...

    The Payroll Department keeps a list of employee information for each pay period in a text file. The format of each line of the file is the following: <last name> <hourly wage> <hours worked> Write a program that inputs a filename from the user and prints to the terminal a report of the wages paid to the employees for the given period. The report should be in tabular format with the appropriate header. Each line should contain: An employee’s name...

  • Programming Exercise 4.12 The Payroll Department keeps a list of employee information for each pay period...

    Programming Exercise 4.12 The Payroll Department keeps a list of employee information for each pay period in a text file. The format of each line of the file is the following: <last name> <hours worked> <hourly wage> Write a program that inputs a filename from the user and prints to the terminal a report of the wages paid to the employees for the given period. The report should be in tabular format with the appropriate header. Each line should contain:...

  • I am having a hard time with my program to assignment 4.12. Here are the instructions:...

    I am having a hard time with my program to assignment 4.12. Here are the instructions: The Payroll Department keeps a list of employee information for each pay period in a text file. The format of each line of the file is the following: <last name> <hours worked> <hourly wage> Write a program that inputs a filename from the user and prints to the terminal a report of the wages paid to the employees for the given period. The report...

  • You are to write a program that will process employees and their pay. For each employee...

    You are to write a program that will process employees and their pay. For each employee the program will read in an employee’s name and hourly pay rate. It should also read in the number of hours worked each day for 5 days and calculate his or her total number of hours worked. You must read the hours using a loop. The program should output the employee’s name, gross pay, total withholding amount and net pay. Withholding is made up...

  • In C++ Please please help.. Assignment 5 - Payroll Version 1.0 In this assignment you must create and use a struct to hold the general employee information for one employee. Ideally, you should use an...

    In C++ Please please help.. Assignment 5 - Payroll Version 1.0 In this assignment you must create and use a struct to hold the general employee information for one employee. Ideally, you should use an array of structs to hold the employee information for all employees. If you choose to declare a separate struct for each employee, I will not deduct any points. However, I strongly recommend that you use an array of structs. Be sure to read through Chapter...

  • In C program Consider a file that contains employee records, called "empstat.txt." The data for each...

    In C program Consider a file that contains employee records, called "empstat.txt." The data for each employee consist of the employee’s last name (up to 20 characters), employee id number (up to 11 characters), gross pay for the week (double), taxes deducted (double) for the week, and net pay (double) for the week. Create a struct to hold the employee information. Write a void function called writeEmpFile that prompts the user to enter last name, id number, gross pay and...

  • in csis 152 style python programming language Read the initial employee information from a text file...

    in csis 152 style python programming language Read the initial employee information from a text file and store the employee information into a list of sublists called empRoster. Each sublist should contain [empID, name, payrate,hours] Here's an example of how empRoster will look: 111, "Sally Smith", 10, 401, 1222, "Bob Brown", 10, 42]1 The text file will be structured as shown below, where each line contains the employee id, employee name, payrate and hours. Each entry on the line is...

  • Spreadsheet Accounting 280 Payroll 279 Exercise 9-1: Employee Earnings Record 1 Prepare an employee earnings record...

    Spreadsheet Accounting 280 Payroll 279 Exercise 9-1: Employee Earnings Record 1 Prepare an employee earnings record for Carol's Surf Shop for the employee shown below. 3211 North Ilikai Boulevard Honolulu, HI 96810 (808) 555-6122 Jackie Scruggs Address Name 433-55-8988 1/10/1973 3/1/1998 SSN Date of Birth Date Hired Telephone Terminated Sex 1 Exemptions Single $12.50 Status Pay Rate The earnings data for Jackie Scruggs is: 2. FIT Total Period Ending Hours Withholdings 1/5/04 1/12/04 1/19/04 1/26/04 2/2/04 2/9/04 27.00 47.00 29.00...

  • In C++ Write a menu driven C++ program to read a file containing information for a list of Students, process the data, t...

    In C++ Write a menu driven C++ program to read a file containing information for a list of Students, process the data, then present a menu to the user, and at the end print a final report shown below. You may(should) use the structures you developed for the previous assignment to make it easier to complete this assignment, but it is not required. Required Menu Operations are: Read Students’ data from a file to update the list (refer to sample...

  • I am really struggling with this assignment, can anyone help? It is supposed to work with...

    I am really struggling with this assignment, can anyone help? It is supposed to work with two files, one that contains this data: 5 Christine Kim # 30.00 3 1 15 Ray Allrich # 10.25 0 0 16 Adrian Bailey # 12.50 0 0 17 Juan Gonzales # 30.00 1 1 18 J. P. Morgan # 8.95 0 0 22 Cindy Burke # 15.00 1 0 and another that contains this data: 5 40.0 15 42.0 16 40.0 17 41.5...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT