24/7 Homework Help

Studykind Will Help You Write Your Essays and Term Papers

From initial topic to finished paper


Problem Description using CBig Jim is opening a new pizza r

by | Aug 8, 2022 | Recent Orders

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 HausId Name Age Salary—— ————————— —– ————–1 Bob Roberts 42 35040.002 Maxwell Smart 37 21000.00Total Employees: 2Total salary: 56040.00Average salary: 28020.00If a report is requested and there are no employees, your program should output:Employee Report for Big Jim’s Pizza HausId 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 intis a string (you must dynamically allocate as a char * of appropriate size) is an intis a doubleThe format of a reporting transaction is simply:REPORTYour 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.This is what I have so far and it compiles. It does not match what the assignment is asking for. Please Help!#include



typedef struct employeeData{    int EMP_ID;    char name[20];    int dep;    int age;    double salary;} emp;typedefstruct node{    structemployeeData emp;    struct node* next;}node;node* head=NULL;node* initializelist(){       emp E;    FILE *fp;    fp = fopen(’empinfo.txt’,’r’); // read mode       if( fp == NULL )    {        perror(‘Error while opening the file.n’);        exit(EXIT_FAILURE);    }    int id;    char* nam;    nam=(char*)malloc(20*sizeof(char));    int a,b;    double c;    fscanf(fp, ‘%d %s %d %d %lf’, &id, nam, &a, &b,&c);    E.EMP_ID=id;    strcpy(E.name, nam);    E.dep=a;    E.age=b;    E.salary=c;    head=(node*)malloc(sizeof(node));    head->emp=E;    head->next=NULL;    node* p=head;    node* temp;    while(fscanf(fp, ‘%d %s %d %d %lf’, &id,nam, &a, &b,&c) != EOF) {        temp=(node*)malloc(sizeof(node));        E.EMP_ID=id;        strcpy(E.name, nam);        E.dep=a;        E.age=b;        E.salary=c;        temp->emp=E;        p->next=temp;        temp->next=NULL;        p=temp;    }    fclose(fp);       return head;}node* add(){       int a,b,c;    double d;    char nam[20];    scanf(‘%d %s %d %d %lf’,&a,nam,&b,&c,&d);    emp e;    e.EMP_ID=a;    strcpy(e.name, nam);    e.dep=b;    e.age=c;    e.salary=d;    if(head==NULL){        head=(node*)malloc(sizeof(node));        head->emp=e;        head->next=NULL;        printf(‘Addition complete n’);        return head;    }    node* p=head,*q=NULL;    while(p->emp.EMP_ID

next;    }    node* temp=(node*)malloc(sizeof(node));    if(p==head){                      temp->emp=e;        temp->next=head;        head=temp;        printf(‘Addition complete n’);        return head;    }       temp->next=p;    q->next=temp;    printf(‘Addition complete n’);    return head;   }node* deleteemp(int id){       node* p=head,*q;       while(p->emp.EMP_ID!=id){               q=p;        p=p->next;    }    if(p==head){               head=p->next;        free(p);        printf(‘deletion completed n’);        return head;    }    q->next=p->next;    free(p);       printf(‘deletion completed n’);       return head;   }node* modify(int id,double s){       node* p=head,*q;       while(p->emp.EMP_ID!=id){        p=p->next;    }       if(p!=NULL){               p->emp.salary=s;           }    printf(‘modification completed n’);    return head;}void query(int r){       node* p=head;    while(p!=NULL){               if(p->emp.age==r){            printf(‘names of employee with age %d n’,r);            printf(‘%s n’,p->emp.name);        }        p=p->next;           }   }void print(){       node* p=head;    printf(‘DETAILS OF ALL EMPLOYEES n’);    while(p!=NULL){               printf(‘%d %s %d %d %lf n’,p->emp.EMP_ID,p->emp.name,p->emp.dep,p->emp.age,p->emp.salary);        p=p->next;           }   }int main(){       head=initializelist();    int choice,id,r;    double s;    while(1){               printf(‘******menu***** n’);        printf(‘1. ADD EMPLOYEEn’);        printf(‘2. DELETE EMPLOYEE n 3. MODIFY SALARY n 4.QUERY n5.PRINT DETAILSn’);        printf(‘ENTER your choice n’);        scanf(‘%d’,&choice);        if(choice==1){                       head=add();        }        if(choice==2){                       printf(‘Enter emp id to delete n’);            scanf(‘%d’,id);            head=deleteemp(id);        }        if(choice==3){                       printf(‘Enter emp id and modified salary n’);            scanf(‘%d %lf’,&id,&s);            head=modify(id,s);        }        if(choice==4){            printf(‘Enter age n’);            scanf(‘%d’,&r);            query(r);                   }        if(choice==5){                       print();        }        if(choice==0)            return 0;           }      }
){ >


Why Place An Order With Us?

  • Certified Editors
  • 24/7 Customer Support
  • Profesional Research
  • Easy to Use System Interface
  • Student Friendly Pricing

Have a similar question?

Services that we offer

Your Paper Is In Safe Hands


All papers we provide are well-researched, properly formatted and cited.


All papers we provide are well-researched, properly formatted and cited.


All papers we provide are well-researched, properly formatted and cited.

Related Assignments

My Progect Assessment

Using the Internet for your research, complete the following exercise. Find an example of a real project with a real project manager. Feel free to...

read more

Study more efficiently

Quickly get your essay from idea to final graft save time, money and effort.

Boost your grade

Get through your toughest problem and learn how to solve them from expert writers

Essay Writing Service Ready to Help Online 24/7

Hire a professional just from $9.99

Click here

Open chat
Powered by Essaynice
Hello welcome to our whatsapp support 👋
Can we help you?