Write a computer program that could be used to track, by lab, which user is logg
ID: 3662413 • Letter: W
Question
Write a computer program that could be used to track, by lab, which user is logged onto which computer. For example, if user 49193 is logged into station 2 in lab 3 and user 99577 is logged into station 1 oflab 4, then your system might display the following:LabNumberComputer Stations11: empty 2: empty 3: empty 4: empty 5: empty11: empty 2: empty 3: empty 4: empty 5: empty 6: empty31: empty 2: 49193 3: empty 4: empty41: 99577 2: empty 3: empty
Create a menu that allows the administrator to stimulate the transmission of information by
manually typing in the login of logoff data. Whenever someone logs in or out, the display should
be updated. Also write a search option
so that the administrator can type in a user ID and the
system will output what lab and station number that user is logged into, or “None” if the user ID
is not logged into any computer station.
You should use a fixed array of length 4 for the labs. Each
array entry points to an
array that
stores the user login information for each respective computer station.
The structure is shown in the figure below. This structure is sometimes called a ragged array
since the columns are of unequal length.
You may ass
ume that the number of computers in each
lab is fixed and specified during compilation time.
Explanation / Answer
#include using namespace std; // Function declaration int get_menu(); void store_data(int, int, int); void search_user(int); bool process_menu(int); void set_data(); void print_data(); // Constant vars const int LABS = 4; // The Labs int *labs[LABS]; int lab_size[LABS]; typedef int* Stations; int main() { set_data(); while(process_menu(get_menu())); return 0; } // Set up the data void set_data() { for (int i=0;i user; search_user(user); break; case 3: print_data(); break; } return true; } // Store the data in the array. void store_data(int id, int station, int lab) { Stations temp = labs[lab-1]; temp[station-1] = id; } // Search for the user and print the chart. void search_user(int id) { int lab, station; for (int i=0; iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.