Question

C++ program that could be used to track, by lab, who is logged into which computer

1. |15 points| Suppose you run four computer labs. Each lab contains computer stations that are numbered as shown in the tablMAIN MENU 0) Quit 1) Simulate login 2) Simulate logoff 3) Search Enter the 5 digit ID number of the user logging in: 12345 En

1. |15 points| Suppose you run four computer labs. Each lab contains computer stations that are numbered as shown in the table below Lab Number |Computer Station Numbers 1-5 2 1-4 1-3 Each user has a unique five-digit ID number. Whenever a user logs on, the user's ID, lab number, and the computer station number are transmitted to your system. For instance, if user 49193 logs onto the station 2 in lab 3, then your system receives (49193, 2, 3) as input data. Similarly, when a user logs off a station, then your system receives the lab number and computer station number Write a C++ program that could be used to track, by lab, which user is logged onto which computer. For example, if user 49193 is logged into the station 2 in lab 3 and user 99577 is logged into the station 1 of lab 4, then your system should display the following: Lab Number Computer Stations 1: empty 2: empty 3: empty 4: empty 5: empty l: empty 2: empty 3: empty 4: empty 5: empty 6: empty 1: empty 2: 49193 3: empty 4: empty 1: 995772: empty 3: empty Create a menu that allows the administrator to simulate the transmission of information by manually typing in the login or 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 a dynamic array that stores the user login information for each respective computer station Sample Input and Output: Lab # Con!puter Stations 1: empty 2: empty 3: empty 4: empty 5: empty l: empty 2: empty 3: empty 4: empty 5: epty 6: empty 1: empty 2: empty 3: empty 4: empty 1: empty 2: empty 3: empty
MAIN MENU 0) Quit 1) Simulate login 2) Simulate logoff 3) Search Enter the 5 digit ID number of the user logging in: 12345 Enter the lab number the user is logging in from (1-4): 2 Enter computer station number the user is logging in to (1-6): 2 LAB STATUS Lab # Computer Stations 1: empty 2: empty 3: empty 4: empty 5: empty 1: empty 2: 12345 3: empty 4: empty 5: empty 6: empty 1: empty 2: empty 3: empty 4: empty 1: empty 2: empty 3: empty 2 MAIN MENU 0) Quit 1) Simulate login 2) Simulate logoff 3 Search Enter the 5 digit ID number of the user logging in: 49193 Enter the lab number the user is logging in from (1-4): 3 Enter computer station number the user is logging in to (1-5): 3 LAB STATUS Lab # Computer Stations 1: empty 2: empty 3: empty 4: empty 5: empty 1: empty 2: 12345 3: empty 4: emptv 5: empty 6: empty 1: empty 2: empty 3: 49193 4: empty 1: empty 2: empty 3: empty MAIN MENU 0) Quit 1) Simulate login 2) Simulate logoff 3) Search 3 Enter the 5 digit ID number of the user to find: 12345 User 12345 is in lab 2 at computer 2 0) Quit 1 Simulate login
0 0
Add a comment Improve this question Transcribed image text
Answer #1

//code self understandable

#include <bits/stdc++.h>
#define LAB_NO 4
#define FIRST_LAB 5
#define SECOND_LAB 6
#define THIRD_LAB 4
#define FOURTH_LAB 3
using namespace std;
void print(int** lab)
{
   cout<<"LAB STATUS"<<endl;
   cout<<"LAB# "<<"Computer Stations"<<endl;
   cout<<"1 ";
   for(int i=0;i<5;i++)
   {
       if(lab[0][i]==0)
       cout<<i+1<<": empty ";
       else
       cout<<i+1<<": "<<lab[0][i]<<" ";
   }
   cout<<endl;
   cout<<"2 ";
   for(int i=0;i<SECOND_LAB;i++)
   {
       if(lab[1][i]==0)
       cout<<i+1<<": empty ";
       else
       cout<<i+1<<": "<<lab[1][i]<<" ";
   }
   cout<<endl;
   cout<<"3 ";
   for(int i=0;i<THIRD_LAB;i++)
   {
       if(lab[2][i]==0)
       cout<<i+1<<": empty ";
       else
       cout<<i+1<<": "<<lab[2][i]<<" ";
   }
   cout<<endl;
   cout<<"4 ";
   for(int i=0;i<FOURTH_LAB;i++)
   {
       if(lab[3][i]==0)
       cout<<i+1<<": empty ";
       else
       cout<<i+1<<": "<<lab[3][i]<<" ";
   }
   cout<<endl;
}
void search(int user_id,int** lab)
{
   for(int i=0;i<FIRST_LAB;i++)
   {
       if(lab[0][i]==user_id)
       {
           cout<<"User "<<user_id<<" is in lab 1 at computer "<<i+1<<endl;
           return;
       }
   }
   for(int i=0;i<SECOND_LAB;i++)
   {
       if(lab[1][i]==user_id)
       {
           cout<<"User "<<user_id<<" is in lab 2 at computer "<<i+1<<endl;
           return;
       }
   }
   for(int i=0;i<THIRD_LAB;i++)
   {
       if(lab[2][i]==user_id)
       {
           cout<<"User "<<user_id<<" is in lab 3 at computer "<<i+1<<endl;
           return;
       }
   }
   for(int i=0;i<FOURTH_LAB;i++)
   {
       if(lab[3][i]==user_id)
       {
           cout<<"User "<<user_id<<" is in lab 4 at computer "<<i+1<<endl;
           return;
       }
   }
   cout<<"User "<<user_id<<" is not present in any of the labs"<<endl;
   return;
}
int main() {
   // your code goes here
   int** lab=new int*[4];
   lab[0]=new int[FIRST_LAB];
   lab[1]=new int[SECOND_LAB];
   lab[2]=new int[THIRD_LAB];;
   lab[3]=new int[FOURTH_LAB];
   memset(lab[0],0,FIRST_LAB*sizeof(int));
   memset(lab[1],0,sizeof(lab[1]));
   memset(lab[2],0,sizeof(lab[2]));
   memset(lab[3],0,sizeof(lab[3]));
   while(1<2)
   {
       cout<<"MAIN MENU"<<endl;
       cout<<")0 QUIT"<<endl<<"1) SIMULATE LOGIN"<<endl<<"2) SIMULATE LOGOFF"<<endl<<"3) SEARCH"<<endl;
       int choice;
       cin>>choice;
       if(choice==0)
       break;
       else if(choice ==1)
       {
           int user_id,lab_no,computer_no;
           cout<<"Enter the 5 digit ID number of the user logging in ";
           cin>>user_id;
           cout<<"Enter the lab number the user is logging in from(1-4) ";
           cin>>lab_no;
           cout<<"Enter the computer station number the user is logging in to(1-6) ";
           cin>>computer_no;
           lab[lab_no-1][computer_no-1]=user_id;
           print(lab);

       }
       else if(choice==2)
       {
           int lab_no,computer_no;
           cout<<"Enter the lab number the user is logging of from(1-4) ";
           cin>>lab_no;
           cout<<"Enter the computer station number the user is logging of to(1-6) ";
           cin>>computer_no;
           lab[lab_no-1][computer_no-1]=0;
           print(lab);
       }
       else if(choice==3)
       {
           int user_id;
           cout<<"Enter the 5 digit ID number of the user to find ";
           cin>>user_id;
           search(user_id,lab);
       }
   }
   return 0;
}

Add a comment
Know the answer?
Add Answer to:
C++ program that could be used to track, by lab, who is logged into which computer
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • JAVA Programming Assignment: You run four computer labs. Each lab contains computer stations that are numbered...

    JAVA Programming Assignment: You run four computer labs. Each lab contains computer stations that are numbered as shown in the table below:- Lab Number   Computer Station Numbers 1   1-5 2   1-6 3   1-4 4   1-3 Each user has a unique five-digit ID Number. Whenever a user logs on, the user's ID, Lab Number, and the computer station are transmitted to your station. For example, if user 49193 logs onto station 2 in Lab 3, your system receives (49193, 2, 3)...

  • Java Computer Labs Assignment! The code NEEDS to be commented properly! Every class file should have a header comment that includes your name and assignment number and briefly documents what the prog...

    Java Computer Labs Assignment! The code NEEDS to be commented properly! Every class file should have a header comment that includes your name and assignment number and briefly documents what the program does! If there are known deficiencies with your program such as known problems or incomplete features, these should be clearly listed in the header comment! Every method should have a method header comment that documents what the method does, what its parameters are, and what it returns! You...

  • Write the following program in C++ You run four computer labs, Each lab contains computer stations...

    Write the following program in C++ You run four computer labs, Each lab contains computer stations that are numbered as shown in the table below: Lab Number Computer Station Numbers 1 1 - 5 2 1 - 6 3 1 - 4 4 1 - 3 Each user has a unique five-digit ID number. Whenever a user logs on, the user’s ID, lab number, and the computer station number are transmitted to your system. For example, if user 49193 logs...

  • Please post the code in c++! Computer Labs Write a Computer Labs program to store the...

    Please post the code in c++! Computer Labs Write a Computer Labs program to store the list of user IDs for each computer station using a linked list. Problem Description: You run four computer labs. Each lab contains computer stations that are numbered as shown in the table below: Lab Number Computer station Numbers 1-5 2 1-6 1-4 4 1-3 Each user has a unique five-digit ID number. Whenever a user logs on, the User's ID, labnumber, and the computer...

  • #include <iostream> #include <cstdlib> using namespace std; int **dynArray(int row, int cols) { int **myPtr; int...

    #include <iostream> #include <cstdlib> using namespace std; int **dynArray(int row, int cols) { int **myPtr; int lab[4]; myPtr = new int *[row]; for(int i = 0; i < row; i++) myPtr[i] = new int[lab[i]]; for(int i = 0; i<row ; i++) if(myPtr[i] == 0) cout<<"empty"; return myPtr; } void getinput(int ID,int &Station,int &labnumb) { cout<<" Enter your ID number: "<<endl; cin>>ID; cout<<" Enter your station number: "<<endl; cin>>Station; cout<<" Enter your lab number: "<<endl; cin>>labnumb; return; } void logout(int ID,int...

  • In this assignment, you will implement a simple version of Computer Lab administration system in C++....

    In this assignment, you will implement a simple version of Computer Lab administration system in C++. Your program will monitor computers in 4 computer labs and will allow users to log in and log out. Each computer lab has different number of computers. •Lab 1 has 10 computers •Lab 2 has 6 computers •Lab 3 has 3 computers •Lab 4 has 12 computers Here is an example state of the system: Lab Array Some of the computers are free (no...

  • computer science

    CSCI 3000 Homework 4In this assignment, you will implement a simple version of Computer Lab administration system in C++. Your program will monitor computers in 4 computer labs and will allow users to log in and log out. Each computer lab has different number of computers.·      Lab 1 has 10 computers·      Lab 2 has 6 computers·      Lab 3 has 3 computers·      Lab 4 has 12 computersHere is a sample state of the system:Lab ArraySome of the computers are free (no...

  • PLease IN C not in C++ or JAVA, Lab3. Write a computer program in C which...

    PLease IN C not in C++ or JAVA, Lab3. Write a computer program in C which will simulate a calculator. Your calculator needs to support the five basic operations (addition, subtraction, multiplication, division and modulus) plus primality testing (natural number is prime if it has no non-trivial divisors). : Rewrite your lab 3 calculator program using functions. Each mathematical operation in the menu should be represented by a separate function. In addition to all operations your calculator had to support...

  • Language: C++ PLEASE INCLUDE SCREENSHOT OF OUTPUT In this assignment, you will consider the problem of organizing a collection of computer user-ids and passwords. Each time a user logs in to the syste...

    Language: C++ PLEASE INCLUDE SCREENSHOT OF OUTPUT In this assignment, you will consider the problem of organizing a collection of computer user-ids and passwords. Each time a user logs in to the system by entering his or her user-id and a secret password, the system must check the validity of this user-id and password to verify that this is a legitimate user. Because this validation must be done many times each day, it is necessary to structure this information in...

  • Java 7.17 Clone of LAB*: Program: Soccer team roster This program will store roster and rating...

    Java 7.17 Clone of LAB*: Program: Soccer team roster This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balanced team. (1) Prompt the user to input five pairs of numbers: A player's jersey number (0-99, but this is NOT enforced by the program nor tested) and the player's rating (1-9, not enforced like jersey numbers). Store the jersey numbers in one int array and the ratings in another int...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT