Winter 2021 CST8234 – C Programming XXXXXXXXXXDue Date: April 11th, XXXXXXXXXX:59) Assignment #2 (10% weightage) Employee Database Implementation Problem Statement Specifications: This assignment will...

1 answer below »
Document attached


Winter 2021 CST8234 – C Programming Due Date: April 11th, 2021 (23:59) Assignment #2 (10% weightage) Employee Database Implementation Problem Statement Specifications: This assignment will be to implement a program to maintain an employee database, with each employee represented by his/her name, gender, age and job description. You are provided with the structure to be used to represent the information for each employee. Your task will be to build the lower level functions that build and manipulate the database using a single linked list. You will represent the employee database as a list of nodes inside your self-referential structure, one per employee, each containing the relevant name, gender, age and job description for the employee. The struct Employee declaration is as follows: #define MAX_NAME_LENGTH 100 #define MAX_JOB_LENGTH 100 /* Employee structure*/ struct Employee { /* Employee details */ /* pointers to next employee structures in the linked list*/ struct Employee *next; }; Representing Employee Database using LL In your program you will manipulate struct Employee structures to construct and alter the database. Now, set the maximum number of employees in our database dynamically. Allow at least 150 employees. Here is a simple program using dynamic memory allocation. #include #include #include int main ( int argc, char *argv[] ) { char *string; int length = 200; string = (char *) malloc(length); strcpy ( string, "This is a string that fits easily into 200 bytes" ); printf ( "String: %s\n", string ); free ( string ); return 0; } Winter 2021 CST8234 – C Programming Due Date: April 11th, 2021 (23:59) Assignment #2 (10% weightage) Your linked list should look like this: Requirements: In order to successfully complete this program and obtain all the marks, you will need to: 1) When submitting the files, you MUST follow the name specification as described in the end of each part of the assignment. Failing to follow the name specification will result in a penalty of 10 percent reduction from your final mark. 2) If either the name or job description is longer than the specified maximum length, it should be truncated. 3) Make sure memory used to declare the array size doesn’t get wasted, specifically, in case when the database has insufficient memory to hold the data of the employees. 4) Your database must not be inefficient in implementing important operations, especially as the elements of the array are maintained in a specific order (say names are stored in alphabetical order). 5) Write a program must implement ALL the requirements, explicit and implicit, listed in the “Problem Statement Specifications” above. 6) You must distribute your functions in a meaningful manner across .c and .h files. The .c files should contain functions that represent sensible groupings of functionality. You must define .h Winter 2021 CST8234 – C Programming Due Date: April 11th, 2021 (23:59) Assignment #2 (10% weightage) files as appropriate 7) Each function must have a header comments that explain what it does, and describe and/or explain its inputs (if any) and return value (if any) 8) You must submit makefile, .c and .h files of your properly commented code. 9) Your program should present information to the user in clear way. 10) Your program should compile with the flags -Wall -ansi –pedantic Deliverables: • Create a folder called algonquinUserID1_algonquinUserID2_A1 (e.g., “mynam00123_yourna45678_A1”) that represents the two members of your team. Only one submission per group is required. You must submit your .c files in the assigned submission folder on BRS section 010 (activities -> Assignments). We don’t need your entire project folder. • You will need to demo this code in your lab session, the week of April 12-16th, 2021. During demonstration, you must be able to answer any questions related to the assessment. Marking Scheme Item Penalty Coding correctness (functions’ structure) is substandard 3 marks Inappropriate and Inefficient Logic 5 marks Addition of employees to database is incorrect 10 marks Deletion of employees doesn’t work Upto 10 marks Missed demonstration 15 marks Input validation is inacceptable 10 marks Total Marks Achieved ___Out of 40. Problem Statement Specifications:
Answered 6 days AfterMar 27, 2021

Answer To: Winter 2021 CST8234 – C Programming XXXXXXXXXXDue Date: April 11th, XXXXXXXXXX:59) Assignment #2...

Arun Shankar answered on Mar 30 2021
136 Votes
employee.h
#ifndef EMPL_H
#define EMPL_H
#define MAX_NAME_LENGTH 100
#define MAX_JOB_LENGTH 100
/* Employee structure*/
struct E
mployee
{
/* Employee details */
char name[MAX_NAME_LENGTH];
int age;
char gender;
char job[MAX_JOB_LENGTH];
/* pointers to next employee structures in the linked list*/
struct Employee *next;
};
#endif
main.c
#include
#include
#include
#include "employee.h"
void print_header()
{
printf("\nGender\tAge\tName\tJob\n");
printf("--------------------------\n");
}
void print_lines()
{
printf("\n");
int i;
for(i = 0; i < 50; i++)
printf("-");
}
int get_choice()
{
print_lines();
printf("\n\t\t\t1. Search employee");
printf("\n\t\t\t2. Add employee");
printf("\n\t\t\t3. Delete employee");
printf("\n\t\t\t4. View all employees");
printf("\n\t\t\t5. Quit");
print_lines();
printf("\nEnter your choice [1-5]: ");
int choice;
scanf("%d", &choice);
print_lines();
return choice;
}
struct Employee* head = NULL;
void free_memory(struct Employee* ptr)
{
if(ptr == NULL)
return;
else
{
free_memory(ptr -> next);
free(ptr);
}
}
void add_employee()
{
int age;
char gender;
char name[MAX_NAME_LENGTH];
char job[MAX_JOB_LENGTH];
char ignore;
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here