Write a system to read from a file list of employee payroll

Assignment Help C/C++ Programming
Reference no: EM131299902

Assignment

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:

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 );
}

Reference no: EM131299902

Questions Cloud

What rate of return should jacobs require on a project : What rate of return should Jacobs require on a project of average risk?- If a new venture is expected to have a beta of 1.6, what rate of return should Jacobs demand on this project?
Write a program that design a class named month : Design a class named Month . The class should have the following private members: name A string object that holds the name of a month, such as "January," "February," etc.
Main types of linux commands : Which of the following is not one of the three main types of Linux commands?
Create a text file with one record of text data : Create a text file with one record of text data. This text file will be read by the program and the data in the text file will serve as a search term.
Write a system to read from a file list of employee payroll : 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.
What is the current market price of these bonds : Western Enterprises' bonds have 10 years remaining to maturity. Interest is paid annually, the bonds have a $1,000 par value, and the coupon rate is 9 percent. The bonds have a yield to maturity of 7 percent. What is the current market price of th..
What is the post merger eps : Calculate the merger premium and the exchange ratio:- What is the post-merger EPS?- Is there any evidence of dilution of ownership or earnings in either merger transaction?
Prepare the budgets for june : Prepare the budgets for June Revenue, Production, Material usage and Material purchase ( how many pounds of material should be purchased and what is the cost of purchases)
Quality of digital video output : Identify and explain the three factors that influence the quality of digital video output.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  To reverse the order of elements on a stack

Write a program in C++ to  reverse the order of elements on a stack S using two additional stacks using one additional stack

  Create a program that will round a floating point

Create a program that will round a floating point value to a specified number of decimal places as input by the user. To perform the actual calculation, write a function that takes the user's value and the number of decimal places as input paramet..

  Why does the neverwet spray protect it from water

As is know, acetone is a polar molecule like water, so isn't it suppose to mix? So my question is: why does the Neverwet spray protect it from water but not from oils and detergents?

  Write a function that returns a pointer to an array

Write and show a function that takes an integer n and returns a pointer to an array of the first n cubes (0, 1, 8, 27, and so on).

  End of the string and then print the results

Write a C++ code that declares a regular C++ null-terminated string that holds upto 20 characters, reads user input into the string, appends an exclamation to the end of the string and then print the results.

  Program that will calculate the heat transfer of a substance

write a program that will calculate the heat transfer of a substance (water) given three different shapes. The user has to be able to input the type of shape, so that the computer can calculate area, and plug it back in to the equation for heat trans..

  Explain the rand() in detail with example

The student should be able to test himself in addition, substraction, multiplication, divission giving integer (we use possitive numbers)

  C++ programming uml diagrams

The goal of this lab is to better familiarize you with polymorphism and the factory design pattern, two key components in Assignment

  Implement the bounded stack with a concrete class

Using Eclipse, implement the bounded stack with a concrete class names

  A charitable organization wants to design a special atm

A charitable organization wants to design a special ATM machine to be used by needy people.   The association supplies the needy person with a pin number to be able to use the ATM machine.   He/she can then retrieve up to $150 per day depending on..

  Write a recursive and iterative versions of binary search

In C++ write a recursive and iterative versions of binary search and compare their run times using the array a[i]=i, i=0,..., n-1 and the given test method:

  Application which will read a file of daily payments

C++ application which will read a file of daily payments, calculate the total as well as the average payment, display the results to the screen and write the results to a file. The input and output file names should be provided as command line argume..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd