Objective:
The purpose of this project is to expose you to:
One-dimensional parallel arrays, input/output, Manipulating summation, maintenance of array elements. In addition, defining an array type and passing arrays and array elements to functions.
Problem Specification:
The PC Pine Furniture Company has recently hired you to help them generate a payroll report for all their employees. You are given a data file containing the employee’s data. The data for each employee consists of the employee id, name, hours worked and rate of pay. The number of employees in the file is unknown. However; the last employee id number is 0.You are to read this data into parallel arrays, calculate the gross pay, federal withholdings, state withholdings, hospitalization and net pay for each employee and store each in an array. You should define the followings as constants:
• Federal withholding tax rate: 18%
• State withholding tax rate: 4.5%
• Social Security withholding: 2%
Your output should be:
• A report for all employees written to a file and consisting of the employee name, id number, gross pay and net pay.
• Another report written to a different file containing the total gross pay paid to all employees, total federal withholdings, total state withholdings, total Social Security withholding and total for all withholdings.
Requirements:
• Comment thoroughly.
• Every function must have specifications in the form of comments.
• Create global constants.
• Make sure every function accomplishes a task and is self-contained
• Use typedef to define new types as necessary.
• Each file has a heading and column labels to identify information.
• Must test if data file exists before reading data.
• You may need to write additional functions such as total which returns the total of an array.
• main is used as a driver function, no input/output or calculations is done in main, only what is specified.
a counter is used to count the number of elements read.
generate an error if file does not exist, or if not open.
a loop reads the data until the trailing value 0 for ID is encountered.
each function have clear, full and thorough specifications.
the function setdata () reads the data from the file into arrays.
the function setdata() returns the number of employees read from the file as its value.
the function findgross () fills the gross array with calculated data.
the function findwithholding () accepts the needed data for an employee and returns the withholdings.
the function findwithholding () is reused to calculate different withholding.
the function findnet() fills the net array with calculated data.
the function total () will return the total of its array argument. (reused).
headings (), prints the headings and column titles, data/calculated results are printed
Further, without such a description we're left with a large blob of code and no idea what to look for. All you need to do is explain what's wrong with it: a statement or two in the form of "what you expected", vs. "what you got" (i.e., object-deviation format). You'll get better help this way.
I'm not sure what you're asking for but here goes: The information I sent above is thoe code I already wrote in C++, where the requirements were to use parallel arrays. I was supposed to calculate the gross pay, netpay and the taxes. The program came close but the output was part garbage and part good. Better? I don't know what else to say, I'm dying here....
Well, here's a substantial start. You're making too much of a meal out of this and obviously haven't got a plan to work to.
The first step is stated in the problem specification and that is to read in the data and allocate the various bits to parallel arrays.
Then and only then should you start processing it. (I've deliberately started processing in the loop but that is just an expedient for me.) Also I wouldn't complicate the work by starting off worrying about first and last names or formatting the data. They are the last things to worry about.
You'll have to change the file name to suit what you have.
Inside printData you are printing the entire table Size times.
You only need to print it once.
You also need to keep track of the number of records read, so that you don't print the empty entries in the table (which are full of garbage). You return a count parameter that does this, but you never pass it into the printData function.
So grateful for all your help from both of you. However, the premise is that I don't know how many employees there are... Please pardon my ignorance, I've only started doing this January 18th and the course is moving extremely fast without much explanation