Question: Write a C++ program that will allow a research lab manager to monitor the access to a research lab. Each member of the lab has
Write a C++ program that will allow a research lab manager to monitor the access to a research lab. Each member of the lab has access provided by their personal ID Card. Your program will provide information about the timing of the arrivals and departures of the lab staff.
Your program will be provided with a dataset where each row records an event, which is represented by the following information:
1) ID number - a positive integer number
2) Person's name - a string
3) Time of the event - a string in "01:23AM" format
Each event records the use of an ID card to either enter or exit the lab. A given data set corresponds to one day and is already sorted by ID number. You should assume that the lab is empty at the beginning of the day and events are consistent - a given person cannot enter or exit without the event being recorded, a given person cannot enter the
lab twice without exiting once in between, etc.
The program should first read the events from a text file named dataset.txt. It will contain up to 100 events. See the sample file below.
Then, it should offer the user a menu with the following options:
1.Display the events sorted by ID number.
2.Display the events sorted by the time of event.
3.Print the person's name given his/her ID number.
4.Find out whether some person is still in the lab given his/her ID number.
5.Quit
The program should perform the selected operation and then re-display the menu.
Do not change the menu numbers associated with the operations. Display an error message if the user enters an inappropriate number.
For options 1 and 2, display the information for each event on a single, separate line.
The values should line up in columns (use setw). Headers for the table are optional.
For the Lookup operations, label the output values appropriately. For options 2 and 3, If the person is not found, display an appropriate message.
Additional Requirements:
This program must be done in a Linux or Unix environment, using a command line compiler like g++. Do not use codeblocks, eclipse, or Xcode to compile.
The program must be Modular (use top-down design), with significant work done by functions. Each function should perform a single, well-defined task.
Use a partially filled array of structures to store the events:
Use a counter variable to count the number of events that are read in from the file,and use this value as the size of the array for the search and sort functions.
Your program should work for an input file with any number of events up to 100.
You MUST use binary search for option 3, Lookup name by ID.
------------------------------------------------------------------------------------
Your output should look like this:
Menu
1. Display events sorted by ID
2. Display events sorted by time
3. Lookup a person by ID
4. Lookup the presence of the person by ID
5. Quit the Program
Enter your choice: 1
4 Ronnie 10:15AM
4 Ronnie 06:59PM
4 Ronnie 04:02PM
39 Bridgette 12:48PM
39 Bridgette 03:30AM
156 Johnson 10:09PM
156 Johnson 00:47AM
158 Selena 08:17PM
158 Selena 11:39PM
158 Selena 12:25PM
158 Selena 05:20PM
158 Selena 10:19AM
158 Selena 04:12AM
219 Javier 02:21AM
219 Javier 03:34PM
219 Javier 09:17PM
219 Javier 05:11PM
219 Javier 11:11PM
219 Javier 07:32PM
219 Javier 01:01AM
219 Javier 10:02AM
259 Paula 11:09AM
259 Paula 01:40PM
259 Paula 08:51PM
259 Paula 04:41PM
259 Paula 07:10AM
259 Paula 08:09AM
453 Lorelei 12:47PM
457 Nigel 07:54PM
457 Nigel 07:26AM
457 Nigel 01:14PM
604 April 01:07PM
604 April 01:54PM
604 April 04:10AM
604 April 04:56PM
702 Will 08:11AM
702 Will 09:22PM
702 Will 06:17AM
752 Pandora 05:32PM
830 Mathew 05:24AM
830 Mathew 06:01PM
830 Mathew 05:13AM
830 Mathew 07:45AM
830 Mathew 07:02PM
830 Mathew 01:24PM
899 Porsche 08:31AM
899 Porsche 01:10AM
997 Aurelio 12:00PM
997 Aurelio 09:42AM
997 Aurelio 05:06AM
Menu
1. Display events sorted by ID
2. Display events sorted by time
3. Lookup a person by ID
4. Lookup the presence of the person by ID
5. Quit the Program
Enter your choice: 3
Enter id of a person to look for: 899
The name of the person with ID 899 is: Porsche
Menu
1. Display events sorted by ID
2. Display events sorted by time
3. Lookup a person by ID
4. Lookup the presence of the person by ID
5. Quit the Program
Enter your choice: 4
Enter id of a person to look for: 453
The person with ID: 453 is present in the lab
Menu
1. Display events sorted by ID
2. Display events sorted by time
3. Lookup a person by ID
4. Lookup the presence of the person by ID
5. Quit the Program
Enter your choice: 4
Enter id of a person to look for: 219
The person with ID: 219 is absent from the lab
Menu
1. Display events sorted by ID
2. Display events sorted by time
3. Lookup a person by ID
4. Lookup the presence of the person by ID
5. Quit the Program
Enter your choice: 4
Enter id of a person to look for: 355
No person found with ID: 355
Menu
1. Display events sorted by ID
2. Display events sorted by time
3. Lookup a person by ID
4. Lookup the presence of the person by ID
5. Quit the Program
Enter your choice: 7
Please, enter 1, 2, 3, 4 or 5: 5
Exiting the program...
--------------------------------------------------------------
Your dataset.txt file:
4 Ronnie 10:15AM
4 Ronnie 05:32PM
4 Ronnie 10:45PM
4 Ronnie 10:25PM
4 Ronnie 01:36AM
4 Ronnie 03:33PM
4 Ronnie 05:13AM
4 Ronnie 04:32AM
4 Ronnie 06:59PM
4 Ronnie 03:45PM
4 Ronnie 04:02PM
4 Ronnie 09:33AM
4 Ronnie 11:11AM
39 Bridgette 02:24PM
39 Bridgette 12:48PM
39 Bridgette 03:30AM
156 Johnson 10:22AM
156 Johnson 10:09PM
156 Johnson 11:20PM
156 Johnson 00:47AM
156 Johnson 07:23AM
158 Selena 08:17PM
158 Selena 11:39PM
158 Selena 08:20AM
158 Selena 11:17AM
158 Selena 03:24PM
158 Selena 07:56PM
158 Selena 10:55PM
158 Selena 01:09PM
158 Selena 12:25PM
158 Selena 05:20PM
158 Selena 10:19AM
158 Selena 03:08PM
158 Selena 11:01AM
158 Selena 04:12AM
219 Javier 02:21AM
219 Javier 03:34PM
219 Javier 01:31PM
219 Javier 08:28AM
219 Javier 09:17PM
219 Javier 05:11PM
219 Javier 11:11PM
219 Javier 07:32PM
219 Javier 01:01AM
219 Javier 10:02AM
259 Paula 11:09AM
259 Paula 01:40PM
259 Paula 07:22AM
259 Paula 10:01AM
259 Paula 12:54PM
259 Paula 10:14AM
259 Paula 08:51PM
259 Paula 05:26PM
259 Paula 04:41PM
259 Paula 07:10AM
259 Paula 08:09AM
387 Martin 11:59AM
453 Lorelei 12:47PM
457 Nigel 07:54PM
457 Nigel 07:26AM
457 Nigel 03:53PM
457 Nigel 07:04AM
457 Nigel 08:40AM
457 Nigel 12:14PM
457 Nigel 03:50AM
457 Nigel 01:14PM
604 April 01:07PM
604 April 12:32PM
604 April 01:54PM
604 April 06:50AM
604 April 10:47PM
604 April 10:10AM
604 April 04:05PM
604 April 04:10AM
604 April 04:56PM
702 Will 08:11AM
702 Will 02:34AM
702 Will 10:10AM
702 Will 12:51PM
702 Will 01:43AM
702 Will 04:05PM
702 Will 02:37AM
702 Will 01:48PM
702 Will 11:46AM
702 Will 09:22PM
702 Will 06:17AM
752 Pandora 05:32PM
830 Mathew 05:24AM
830 Mathew 06:01PM
830 Mathew 05:13AM
830 Mathew 07:45AM
830 Mathew 08:59PM
830 Mathew 12:31PM
830 Mathew 07:02PM
830 Mathew 01:24PM
899 Porsche 08:31AM
899 Porsche 01:10AM
997 Aurelio 12:00PM
997 Aurelio 09:42AM
997 Aurelio 05:06AM
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
