Question

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:
    • 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
0 1
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
_________________


// data1.txt

Lambert 34 357.00
Osborne 22 137.50
Giacometti 5 503.50
_______________________

#include <iostream>

#include <string>

#include <iomanip>

#include <fstream>

using namespace std;

int main() {
ifstream dataIn;

string filename, name;
int hours;
double totPay;

cout << "Enter the input filename :";
cin >> filename;

//Open the input file
dataIn.open(filename.c_str());
//checking whether the file name is valid or not
if (dataIn.fail()) {
cout << "** File Not Found **";
return 1;
} else {
cout << setw(20) << left << "Name" << setw(10) << left << "Hours" << setw(10) << left << "Total Pay" << endl;
while (dataIn >> name >> hours >> totPay) {
cout << setw(20) << left << name << setw(10) << left << hours << setw(10) << left << totPay << endl;
}
dataIn.close();

}

return 0;
}

___________________________

Output:

I C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\ReadFileAndDisplayNameHours Worked TotalPay.exe Enter the input filename :data1.

_______________Could you plz rate me well.Thank You

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

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
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...

  • 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...

  • 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...

  • PYTHON PROGRAMMING LANGUAGE (NEEDED ASAP) Using a structured approach to writing the program: This section will...

    PYTHON PROGRAMMING LANGUAGE (NEEDED ASAP) Using a structured approach to writing the program: This section will guide you in starting the program in a methodical way. The program will display a window with GUI widgets that are associated with particular functions: Employee Payroll O X -- - - - - - - - - - - Show Payroll Find Employee by Name Highest Lowest Find Employee by Amount Write Output to Fie Cancel - -------- ------------- Notice that some of...

  • (PL/SQL Programming) Consider the table EMPLOYEE with attributes ID, Name, and Hours, and the table PAYINFO...

    (PL/SQL Programming) Consider the table EMPLOYEE with attributes ID, Name, and Hours, and the table PAYINFO with attributes Regular, Overtime, and HourLimit, defined and populated by the following script: DROP TABLE EMPLOYEE CASCADE CONSTRAINTS; CREATE TABLE EMPLOYEE (        ID            CHAR(5),        Name          VARCHAR2(16),        Hours         NUMBER(2),        CONSTRAINT PK_EMPLOYEE               PRIMARY KEY (ID) ); INSERT INTO EMPLOYEE VALUES ('22144', 'Anderson', 30); INSERT INTO EMPLOYEE VALUES ('31902', 'Bruford', 45); INSERT INTO EMPLOYEE VALUES ('42771', 'Wakeman', 20); INSERT INTO EMPLOYEE VALUES...

  • Description: A program is needed for a third-party payroll clearinghouse that supports the following: Calculate employee...

    Description: A program is needed for a third-party payroll clearinghouse that supports the following: Calculate employee pay feature Company total pay feature The employee and company totals are stored in a text file for each individual company. 1. Create the following “input.txt” file. Each record consists of a first name, last name, employee ID, company name, hours worked, and pay rate per hour. Maria    Brown 10 Intel   42.75 39.0 Jeffrey Jackson 20 Boeing   38.0 32.5 Bernard Smith 30 Douglas   25.0...

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