[SOLVED] An organization has many employees. Each employee has the following information: Employee ID, name and salary. For each employee, use a structure defined as follows to record his/her information.

$25

File Name: An_organization_has_many_employees._Each_employee_has_the_following_information:_Employee_ID,_name_and_salary._For_each_employee,_use_a_structure_defined_as_follows_to_record_his/her_information..zip
File Size: 1836.9 KB

5/5 - (1 vote)

An organization has many employees. Each employee has the following information: Employee ID, name and salary. For each employee, use a structure defined as follows to record his/her information.
struct Employee {
int id;
char name[20];
int salary;
struct Employee *id_next;
struct Employee *sl_next;
};

The structure has two pointers, id_next and sl_next, which are used for making two linked lists.
The pointer id_next is used for making a linked list of all employees structures in increasing order of their ID numbers, and a head pointer id_head points to the first structure in this linked list (i.e., the structure with the smallest id value).
The pointer sl_next is used for making a linked list of all employees structures in increasing order of their salaries, and a head pointer sl_head points to the first structure in this linked list (i.e., the structure with the smallest salary value).
The following figure demonstrates an example of the linked lists with information of 5 employees.

Please write a program with the following functions:
DisplayList(), for displaying the information of all structures in the lists. This function should be able to display the structures either in the increasing order of the ID numbers, or in the increasing number of the salaries, depending on the parameter sent to the function.
ExistInList(), for checking whether a structure with the given ID number is already in the lists.
AddToList(), for adding the structure of a new employ to the proper position of the two linked lists. You should decide the parameter list and the return value type of the function by yourself.
RemoveFromList(), for removing the structure of some employee (according to the ID number) from the two linked lists. One of the parameters of this function is an integer representing the ID of the employee to remove. You should decide the other parameters and the return value type of the function by yourself. (When this function is called, it is assumed that the structure to remove must be in the current linked lists).

In the main() function, do the following steps:
Use the function AddToList() to create the linked lists with the employee information shown in the above figure. The structure storing an employee information should be dynamically allocated using malloc.
Use DisplayList() to display all the structures, in the increasing order of the ID numbers.
Use DisplayList() to display all the structures again, in the increasing order of the salaries.
Use ExistInList() to check whether a structure with ID number 8 is in the linked lists and print the results (exist or not exist).
Use ExistInList() to check whether a structure with ID number 2 is in the linked lists. If yes, use RemoveFromList() to remove this structure from the linked lists.
Use ExistInList() to check whether a structure with ID number 5 is in the linked lists. If yes, use RemoveFromList() remove this structure from the linked lists.
Use DisplayList() to display the remaining structures, in the increasing order of the ID numbers.

Grading criteria:
Correctness: 7 marks.
The program can correctly execute the requirement functionalities. The distribution of the marks is as follows:
Correctly create the structure for each employee by dynamic memory allocation: 1 mark
Correctly create the linked lists and display them: 2 marks
Correctly check the existence of a structure with a given ID number: 2 mark
Correctly remove a structure with a given ID number: 2 marks
Good programming style: 1 mark.
The source code are properly structured (e.g., using indents) and well commented.
Bonus: 2 marks.
Other (useful) features beyond the above requirements. If your program includes any bonus feature, please submit a separate WORD document to clearly introduce it and make sufficient comments in the source code to explain the corresponding codes.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] An organization has many employees. Each employee has the following information: Employee ID, name and salary. For each employee, use a structure defined as follows to record his/her information.
$25