OOP2200 Lab 8 Structs and File I/O CPP

Availability: In stock

Regular Price: $15.00

Special Price: $12.00

OR

OOP2200 Lab 8 Structs and File IO main cpp

Double click on above image to view full picture

Zoom Out
Zoom In

More Views

Quick Overview

OOP2200 Lab 8 Structs and File I/O CPP
 
This lab assignment will be completed by pairs of students. Submissions by individual students will not be accepted under normal circumstances. The intent is that the two students work together. In this lab you will be creating 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.
John Smith 25.0 15.00
Mary Jones 33.5 17.50
Pat Brown 40.0 21.00
Jen Simpson 37.5 18.00
Gary Phillips 15.0 11.25


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. (e.g. Thom MacDonald becomes T. MacDonald)
• 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.
YOUR NAME
PAY FOR THIS WEEK
=========================
J. Smith $ 375.00
M. Jones $ 586.25
P. Brown $ 840.00
J. Simpson $ 675.00
G. Phillips $ 168.75
=========================
Total: $ 2645.00


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.
General Requirements
• Include an opening comment with both partner's names, the name of the program, the date, and a short description.
• Follow the course coding standards! Use descriptive names and sensible data-types for variables, constants, functions, etc. that follow our naming conventions.
• Use good spacing and make sure braces ({}) are located where they are supposed to be, and indentation follows Allman style.
• Attach your unzipped source code file(s) (.cpp, .h) to the assignment folder. Nothing else please.

Regular Price: $15.00

Special Price: $12.00

Details

OOP2200 Lab 8 Structs and File I/O CPP
 
This lab assignment will be completed by pairs of students. Submissions by individual students will not be accepted under normal circumstances. The intent is that the two students work together. In this lab you will be creating 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.
John Smith 25.0 15.00
Mary Jones 33.5 17.50
Pat Brown 40.0 21.00
Jen Simpson 37.5 18.00
Gary Phillips 15.0 11.25

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. (e.g. Thom MacDonald becomes T. MacDonald)
• 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.
YOUR NAME
PAY FOR THIS WEEK
=========================
J. Smith $ 375.00
M. Jones $ 586.25
P. Brown $ 840.00
J. Simpson $ 675.00
G. Phillips $ 168.75
=========================
Total: $ 2645.00

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.
General Requirements
• Include an opening comment with both partner's names, the name of the program, the date, and a short description.
• Follow the course coding standards! Use descriptive names and sensible data-types for variables, constants, functions, etc. that follow our naming conventions.
• Use good spacing and make sure braces ({}) are located where they are supposed to be, and indentation follows Allman style.
• Attach your unzipped source code file(s) (.cpp, .h) to the assignment folder. Nothing else please.

Product Tags

Use spaces to separate tags. Use single quotes (') for phrases.