Recent Question/Assignment

Requirements:
must be written in c. (NOT c++ or C#)
Include inline (single line) comments throughout the program describing important statements.
Use appropriate and descriptive variable following the naming rules and conventions.


Question 2
A database of details of employees is kept in a text file as shown below. The entries are employee name, age, department id, company name and salary in that order. A small segment of the file might look like the following.
So, according to the data presented in this file, the first employee’s name is Peter; his age is 30, his department id is 1001, his company name is Apple and has a salary of 3000. The second employee’s name is Joseph; his age is 50, his department id is 1002, his company name is Oracle and has a salary of 4000 and so on.
Step 1: Manually create a text file that contains the employees’ details (minimum 10 employees) as shown in the problem, you can enter your own data for the file, but it should follow the same format. Save the text file as employee.txt.
Use the structure given below for this problem.
Create a LinkedList using the above self-referential structure and read the contents of the text file into LinkedList. Each node of the LinkedList contains details of one employee. Implement all functionalities mentioned below:
The main () function handles all interactions with the user and other functions:
It displays an appropriate welcome message introducing the program. Calls a function named readFile()which opens a text file employee.txt (a sample text file is shown above) for reading and storing all of the employees’ details from the file to a LinkedList in order of name (insertion should happen in alphabetical order). It then repeatedly calls the menu()function to display user options, get the user selection returned by the menu() function, use a switch (or if ..else if) statement to process user request by calling appropriate function(s).
It displays the result with an appropriate message after processing user request.
It displays a goodbye message when the user selects the Quit option from the menu and terminates the program.
The menu()function has no parameters. When called, it displays a menu of 6 options allowing the user to select one and returns this option to the calling main()function. The options displayed should be:
(1) Display employees’ details
(2) Search for an employee’s salary
(3) Find the details of employee with the largest salary
(4) Find the details of all employees having salary less than 5000
(5) Find the average salary of a company
(6) Add new employee to the record
(7) Quit program
Option (1) will use a function called displayEmployees () called from the main () to display the contents of the LinkedList on the screen in an appropriate format.
Option (2) will use a function called searchEmployee()which is designed to search for an employee. Display all the details of that employee, if no such employee is found, report it back to the user.
Option (3) will use a function called findMaximum() which is designed to find the details of employee having the largest salary in the LinkedList. Display all the details of that employee.
Option (4) will use a function called lowerSalary()which is to find the employees who have salary less than 5000. Display all the details of these employees.
Option (5) will use a function called averageSalary() which is used to find the avarage salary of all emplyees of a company. If there is no such company, the program should report it back to the user.
Option (6) will first use a function called updateFile() which will open the same text file in append mode, prompt the user for new employee’s details and then write the new data at the end of the file using the same format as the original file. It will then the call the readFile() function again to read the contents of the updated file and repopulate the LinkedList. Call the display function again to show the employees’ details on screen.
Option (7) will terminate the program after displaying an appropriate goodbye message.
Question 3
In this problem you are required to create an airport system that schedules aeroplanes. Create a structure that contains three elements, first element should store plane id, second element should store route id and third element should store schedule (time). Declare an array of this structure with a size 15.
Function 1: From main call a function (you can give an appropriate name for this function) passing the array (In this problem array means array of the structure) and size of the array as parameters to fill the details of planes in the array. The plane id should be filled with a random integer between 100 and 1000 and route id of that plane should be filled with an integer between 1000 and 2000.
This function should be called first and need to call only once.
Function 2: From main call a function (you can give an appropriate name for this function) passing the array and size of the array as parameters to fill the departure time of the planes (fill the time field of the structure in the array). You can use the sample code provided to fill the time details.
You need to call this function only once and must call only after invoking the function 1.
Function 3: From main call a function (you can give an appropriate name for this function) passing the array and size of the array as parameters to print the details of array (details of all planes – plane id, route id and time) on the screen. You can call this function repeatedly.
Function 4: From main call a function (you can give an appropriate name for this function) passing the array and size of the array as parameters to schedule the planes based on the time field of the plane. The earliest (time value) plane to be placed at the bottom of the array. You need to call this function only once.
Then extend your structure to include a self-referential structure element to create queue and stack using this structure. This self-referential structure should be used for the next two functions. These functions can be called any number of times and in any order but can be called only after scheduling the planes (function 4) based on the time field of the planes.
Function 5: Call a function (you can give an appropriate name for this function) that allows one plane to take off from the airport based on the schedule. Plane with the earliest schedule should leave the depot first.
Function 6: Call a function (you can give an appropriate name for this function) that allows one plane to take off from the airport with the last scheduled plane from the array to leave the airport first (in an emergency).

Looking for answers ?