C Programming question: I don't know where to start...PLEASE HELP.

Dec 8th, 2014
KateS
Category:
Computer Science
Price: $20 USD

Question description

Problem Description using C:

Big Jim is opening a new pizza restaurant and needs a program that reads a data file containing his employee information and prints a summary report of employees and salary. His data file contains two kinds of transactions that his reporting program must process: an employee insertion transaction and a reporting transaction.

An insertion transaction starts with the tag “INSERT” and the rest of the line in the text file contains the employee data Big Jim needs for adding an employee: an employee id, full name, age, and salary. A reporting transaction is a line in the text file containing only the tag “REPORT”.

Your program must read the provided data file line-by-line. When your program encounters an insertion transaction, you must dynamically allocate space to create a new employee struct and store a pointer to the new struct in your dynamically-allocated employees pointer array. If your employee pointer array is full, you must call realloc to allocate additional space in the pointer array to store 5 more pointers. Your array will initially start at a capacity of 0 which means in order to store the first employee, you must allocate space to store 5 pointers (note that you can also use realloc for the initial allocation). Every time you realloc your pointer array, your program should inform the user of the array growth by printing a notification in the following format:

*** Resizing employee array from 5 to 10 ***

When your program encounters a reporting transaction, Big Jim wants a list of all employees in a simple tabular layout along with summary information after the table containing total # of employees, total salary, and average salary. Below is an example (your program MUST follow the same format):

Employee Report for Big Jim's Pizza Haus
Id     Name                         Age          Salary
------ --------------------------- ----- --------------
1       Bob Roberts                   42        35040.00
2       Maxwell Smart                 37        21000.00
Total Employees:            2
Total salary:        56040.00
Average salary:      28020.00

If a report is requested and there are no employees, your program should output:

Employee Report for Big Jim's Pizza Haus
Id     Name                         Age          Salary
------ --------------------------- ----- --------------
no employees to report!

The format of an insertion transaction in the file is a pipe-delimited set of fields:

INSERT||||
is an int
is a string (you must dynamically allocate as a char * of appropriate size) is an int
is a double

The format of a reporting transaction is simply:

REPORT

Your program must use a header file (employee.h) for the definition of the employee struct. Use a typedef in your header file for simplicity and readability. You must keep a dynamically allocated array of pointers in which to store references to your dynamically created employee structs. Don’t try to use a statically allocated array of employee pointers. One of the primary goals of this assignment is to acquaint you with the functions necessary for the dynamic growth of data at runtime.

Add support for a 3rd transaction type in the data file: deletion of an employee record.

A deletion transaction starts with the tag “DELETE” and is always followed by the employee id of the record to delete. To implement deletion, search your employee array (looking through each struct via its pointer) to see if the id matches the one you need to delete. If you find a match, free the employee record appropriately (including the employee name string member) and set the pointer to that struct in the employee pointer array to NULL.


Tutor Answer

(Top Tutor) Daniel C.
(997)
School: Cornell University
PREMIUM TUTOR

Studypool has helped 1,244,100 students

8 Reviews


Summary
Quality
Communication
On Time
Value
Five Star Tutor
Dec 3rd, 2016
" Outstanding Job!!!! "
SjSurvivor143
Nov 18th, 2016
" Thanks for the help. "
Joemoe
Nov 4th, 2016
" <3 it, thanks for saving me time. "
tinytim47
Oct 26th, 2016
" Wow this is really good.... didn't expect it. Sweet!!!! "
pmallory
Oct 22nd, 2016
" Totally impressed with results!! :-) "
mixedballz
Oct 13th, 2016
" excellent work as always thanks for the help "
kiln82
Sep 29th, 2016
" awesome work thanks "
darnay
Sep 20th, 2016
" The best tutor out there!!!! "
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1825 tutors are online

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors