Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a Plain-Old-Data structure to store basic pay record information. You will use that structure to store raw pay record data read from a data

Create a Plain-Old-Data structure to store basic pay record information. You will use that structure to store raw pay record data read from a data file and produce a formatted report as a text file. Raw Data The data file "hours.txt" (provided), stores data for a number of employees. Each employee is recorded as follows: first name, last name, number of hours worked this week, and wage-per-hour. It currently contains the following data, but please note the file your instructor uses to test your program may contain a different number of records.

This is the data in hours.txt file:

PayRecord struct Create a data structure called PayRecord that has data-members for each of the four fields of information we are recording: first name, last name, number of hours worked this week, and wage-per-hour. When you read a line from the input file, you will be storing it in a PayRecord struct. Reading the Input File and Writing to the Output File Read raw data from the "hours.txt" data file (using your PayRecord struct) and produce a report in a file called "pay.txt". The report must contain the following:

Each employee name in the format first initial only, followed by ".", followed by last name. (ex. G. Hardy)

The pay for each employee (hours worked * wage) formatted as currency. The grand total paid to all employees for the week. Use the following may as a guide. You should try to match the format of this report as closely as possible.

Notes: 1. Ensure that both the input and output files open properly. You should not process any file that is not open. Ensure to close both files when complete. 2. Each employee occurs in the data file one time only. If any of the names appear in your report more than once, you have made a logic error. 3. You are not required to output the report to the screen. 4. One viable approach is to read one line from the input file and then write one line to the report in a loop until there are not more records. Another approach is to read all the records in the input file into a vector first, then produce the report from the vector. Either approach is fine. There is no explicit requirement to read and store all of the pay records before you begin writing the report.

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

Recommended Textbook for

Database Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

More Books

Students also viewed these Databases questions