A+ Work





Implement an employee payroll calculator with data modeling (w/ structures) design methods (from the study notes) using the C/C++ programming language. Write a system to read from a file a list of employee payroll information, calculate net salary amounts based on base salary, bonus, and % deduction. Remove salaries from the list based on some specified criteria and print each employee result from the list to the screen.
For this project, you will design your data model as a well-organized data structure in C/C++ and develop a linked list of structures to elegantly implement and operate on a collection of these data objects. Reference the notes entitled “Data structures – linked lists” for help and example code for this project. You may not use any of the STL classes (e.g. vector, list) or a fixed-size array for this project. You must implement a linked list yourself using the example demonstrated in the lecture notes.
Open the following data file on disk containing payroll information for each employee (for information on opening, reading, and closing files, see example code below):
>> Please just use a filler file name, as you cannot access the directory in question.
Each line in the file represents a single employee with four columns of information as follows:
Name BaseSalary Bonus % Deduction

Clark Kent 55000 2500 0.07

Lois Lane 56000 1500 0.06

Tony Stark 34000 2000 0.05
2) Create a data model definition (using a C/C++ struct) to organize and store employee payroll information as discussed in the study notes on data modeling (w/ structures).
3) Upon reading each line, create data structure objects dynamically, store the information, and add to a growing linked list of data structures. You are to read the file under the assumption that you DO NOT know the number of lines in the file ahead of time. Each line must create a dynamic object added to your linked list as in the study notes example.
4) After reading is complete, close the data file.
5) Using a looping statement, cycle through each object in the linked list and calculate the net salary for each employee with the following equations
Deduction = (Base salary + Bonus) * (% deduction)

Net salary = (Base salary + Bonus) – Deduction
6) Remove from the linked list those employee records with net salaries in the following range. You must alter the pointers within the objects of your linked list to skip over employee record objects with net salaries in this range. Using an if statement to simply not print these records does not suffice as removal of an object from the linked list.
45000 < net salary < 60000
7) Print the final list of data objects displaying all information including name, base salary, bonus, deduction, and final net salary in an organized, readable manner to the screen.
8) Comment your code!
Example help given:
Example

If you are unfamiliar with how to open a file on disk, read the information, and close the file, below is an example of how to handle such operations using C system functions (fopen, fscanf, fclose) and C++ file streams to accomplish these tasks. We’ll be addressing C++ streams in detail later in the semester.
/* Open a file, read information, close the file
Assume the file (example.txt) contains a single line
with the following contents:
John Doe 10000 */
#include <stdio.h>
#include <stdlib.h>
#define MAX_STR 100
main()
{
FILE *in; /* file descriptor */
char first[MAX_STR]; /* first name */
char last[MAX_STR]; /* last name */
float salary; /* salary */
/* open a file, check for errors */
if( (in = fopen( "example.txt", "r" )) == NULL )
{
printf( "Error opening file\n" );
exit(1);
}
/* read from the file:
note that since first and last are arrays,
the array name is ***** ***** address of the first
element of the array (first == &first[0])
Note also that fscanf returns the number of items
successfully read */
int nread = fscanf( in, "%s %s %f", first, last, &salary );
/* print information */
printf( "Name: %s %s\n", first, last );
printf( "Salary: %f\n", salary );
/* close the file */
fclose( in );
}