Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

could you please help me with this assignment? I'll really appreciate it ? Definition of the Problem :Using linked list data structure, do the following

could you please help me with this assignment? I'll really appreciate it

?

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Definition of the Problem :Using linked list data structure, do the following basic operations Prepare the necessary functions to create three linked list structures using a data file(employee.txt) and do the following main operations. Insertion, Sorting, Searching, Deletion, and Traversing(Listing) employee.txt file contains the following fields and data in it. Worked Hours Hourly Salary EmpNumber_ Name 7790 MEHMET 3582 CEMAL 7434 ABDULLAH 1229 SERHAT 196.5 212.5 203.0 186.5 12.00 18.50 15.45 22.15 Each record consists of following fields: Employee Number Employee Name Employee Worked Hours in a month Employee Hourly Salary You may define the structure as follows. #include struct employeeInfo { int empNr; char name[15]; float workHours; float hourlySalary; float monthlySalary;/* will be calculated by workHours x hourlySalary */ }; Steps of operation will be done in the following order of steps. 1) (20 points)Read data file(employee.txt) and create a linked list structure which is given below(During this step monthly salary will be calculated).(Solution already given below). Head node of that linked list will be head1. struct node { struct employeelnfo info; struct node *link; }; typedef struct node *NODEPTR; NODEPTR head1, headNum, headNam; . 2) (25 Points) Create two additional sorted linked list structures using linked list structure which has a head node head1 First linked list will be sorted based on name and head node will be headNam. Second linked list will be sorted based on empNr and head node will be headNum as shown in the figure below. . head1 779 MEHMET 196.12. xxxxx 35 CEMA212. 10. XX TAARN pa v 1229 SERHAT 186.5 22.50 headNam 12 PAROLA CEMA21: 7700 MEHME TO 1290 SERHAT 12 headNum 2) (25 Points) Create two additional sorted linked list structures using linked list structure which has a head node head1 First linked list will be sorted based on name and head node will be headNam. Second linked list will be sorted based on empNr and head node will be headNum as shown in the figure below. head1 779 MEHMET 196. 12. XXX.XX 356 CEMAL 212 18. XXXXX ARDIAN 122 SERHAT 186.22.5XXXXX headNam TARLARLA 36 CMA 2121 770 MEHMET 1974 SERHAT 186 headNum 1990 SERHAT CEMA2124 h TARLARDI. LAHA 154 770 MEHMF 1961 3) (5 points) Search a given employee(read employee number from the monitor) and list his node fields using third linked list starting with a head node headNum. Give error message if given employee number is not found. 4) (5 points) Search a given employee(read employee name from the monitor) and list his node fields using second linked list starting with a head node headNam. Give error message if given employee name is not found. 5) (15 Points)Insert a new employee(read employee information using the monitor) into the second and third linked list structure with the head nodes headNum, headNam. 6) (15 points)Delete an employee(read employee number from the monitor) from both linked list structures. Search and find and delete from the second and third linked list structure starting the head nodes headNum, headNam. To create linked list structure(Step1), you may use the following code, and complete the rest of the program. #include #include #include #define NULLO char struct employeeinfo { int empNr; name[15] float workHours; float hourlySalary; float monthlySalary;/* will be calculated by workHours x hourlySalary */ }; struct node { struct employeelnfo info; struct node *link; }; typedef struct node *NODEPTR; NODEPTR getnode(void); void readFilelntoLinkList(NODEPTR *); void list1(NODEPTR); void menu(); int main() { NODEPTR head1, headNum, headNam; int choice; /* Step1 will be done using these two functions head1 = NULL; readFileIntoLinkList(&head1); list1(head1); dol To create linked list structure(Step1), you may use the following code, and complete the rest of the program. #include #include #include #define NULLO struct employeeinfo { int empNr; char name[15]; float workHours; float hourlySalary; float monthlySalary;/* will be calculated by workHours x hourlySalary */ }; struct node { struct employeelnfo info; struct node *link; }; typedef struct node *NODEPTR; NODEPTR getnode(void); void readFilelntoLinkList(NODEPTR *); void list1(NODEPTR); void menu(); int main() { NODEPTR head1, headNum, headNam; int choice; /* Step1 will be done using these two functions head1 = NULL; readFileIntoLinkList(&head1); list1(head1); do{ menu(); scanf("%d",&choice); switch(choice) { // complete each section calling necessary function that you coded case 1:{. break;) case 2:{. .break;) case 3:{. break;) case 4:{. .break;) case 5:. break;) case 6:{. ;} }while(choice!=7); return 0; } // end of main program void readFileIntoLinkList(NODEPTR *head) { NODEPTR p, save; struct employeeinfo temp; FILE *empFile; empFile = fopen("C:\\assgn2Solution\\employee.txt","r"); while (!feof(empFile)) { fscanf(empFile,"%d %s %f %f",&temp.empNr temp.name,&temp.workHours,&temp.hourlySalary); temp.monthlySalary = temp.hourlySalary*temp.workHours: p = getnode; p->info = temp; if (*head == NULL) { *head = p; save = p; } else{ save->link = p; save = p; } p->link=NULL; fclose(empFile); temp.monthlySalary = temp.hourlySalary temp.workHours; p = getnode(); p->info = temp; if (*head == NULL) { *head = p; save = p; } else{ save->link = p; save = p; } } p->link=NULL; fclose(empFile); } void menu { printf(" *********MAIN MENU********** "); printf("1.Create Sorted Link list using Names and List "); printf("2.Create Sorted Link list using Employee Number and List "); printf("3.Search with an employee Number "); printf("4.Search with an Employee Name "); printf("5.Insert a New Employee information "); printf("6.Delete an Employee from both of the link list structure "); printf("7.Exit "); } void list1(NODEPTR head) { NODEPTR save; save = head; while(save!=NULL) { printf("%d %s %f %f %f ",save->info.empNr,save->info.name,save->info.hourlySalary, save ->info.workHours,save->info.monthlySalary); save = save->link; } } NODEPTR getnode() { NODE Rg; q = (NODEPTR) malloc(sizeof(struct node)); return(a); } USER CATALOGUE WILL BE PREPARED WITH THE FOLLOWING HEADLINES: Definition of the problem: Given problem will be explained. User documentation: How can a single user run your program? Describe in details. Input environment: What does your program get as an input of information? Explain the content of your input files. Output environment: What does your program produce? Production of your program will be explained. Software design issues: Describe the main program and functions (if any) your program. Program list: List of the program and Input/Output files. Programming time: How long did you spend to prepare this save = head; while(save!=NULL) { printf("%d %s %f %f %f ", save->info.empNr,save->info.name,save->info.hourlySalary, save ->info.workHours,save->info.monthlySalary); save = save->link; NODEPTR getnode() { NODEPTR C; q = (NODEPTR) malloc(sizeof(struct node)); return(a); } USER CATALOGUE WILL BE PREPARED WITH THE FOLLOWING HEADLINES: Definition of the problem: Given problem will be explained. User documentation: How can a single user run your program? Describe in details. Input environment: What does your program get as an input of information? Explain the content of your input files. Output environment: What does your program produce? Production of your program will be explained. Software design issues: Describe the main program and functions (if any) your program. Program list: List of the program and Input/Output files. Programming time: How long did you spend to prepare this program for the following steps. Analyze and design: Coding: Debugging : Documentation : Total : IMPORTANT NOTE: . SUBMISSION OF THE REPORTS WILL BE ON MS WORD DOCUMENT FORMAT AND WILL BE LOADED ON LMS AND YOUR PROGRAM CHECKING WILL BE DONE BY THE INSTRUCTOR DURING LABARATORY HOURS

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

What is database?

Answered: 1 week ago

Question

What are Mergers ?

Answered: 1 week ago