Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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

ID: 3764582 • Letter: W

Question

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 onto 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 the computer station number. 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 of lab 4, then your system might display the following: Lab# Computer Stations 1 1: empty 2: empty 3: empty 4: empty 5: empty 1 1: empty 2: empty 3: empty 4: empty 5: empty 6:empty 3 1: empty 2: 49193 3: empty 4: empty 4 1: 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 a dynamic 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.

Explanation / Answer

[#include<iostream>

using namespace std;

int *Point;

void screen1();

void logon();

void logoff();

int main(){

screen1();

int entry;

cout<<endl;

do{

cout<<"1: Logon "

<<"2: Logoff. "

<<"3: Search. "

<<"4: End ";

cout<<"Enter a number: ";

cin>>entry;

if(entry==1){

logon();

}

if(entry==2){

logoff();

}

}while(entry<=3);

cout<<endl;

system("pause");

}

void screen1(){

int station1[5],station2[6],station3[4],station4[3];

int lab[5];

for(int x=1;x<=4;x++){

if(x==1){

station1[5];

for(int f=1;f<=5;f++){

station1[f]=0;

}

}

if(x==2){

station2[6];

for(int f=1;f<=6;f++){

station2[f]=0;

}

}

if(x==3){

station3[4];

for(int f=1;f<=4;f++){

station3[f]=0;

}

}

if(x==4){

station4[3];

for(int f=1;f<=3;f++){

station4[f]=0;

}

}

}

int h=1;

for(int a=1;a<=4;a++){

cout<<h<<": ";

if(a==1){

for(int f=1;f<=5;f++){

if(station1[f]==0){

cout<<f<<" empty ";

}

}

cout<<endl;

}

if(a==2){

for(int f=1;f<=6;f++){

if(station2[f]==0){

cout<<f<<" empty ";

}

}

cout<<endl;

}

if(a==3){

for(int f=1;f<=4;f++){

if(station3[f]==0){

cout<<f<<" empty ";

}

}

cout<<endl;

}

if(a==4){

for(int f=1;f<=3;f++){

if(station4[f]==0){

cout<<f<<" empty ";

}

}

cout<<endl;

}

h++;

}

}

void logon(){

int id,station,lab;

cout<<"Enter your 5 digit User ID: ";

cin>>id;

cout<<endl;

cout<<"Enter the lab number: ";

cin>>lab;

cout<<endl;

switch(lab){

case 1:

cout<<"Enter your station(1-5) ";

cin>>station;

if(station>5){

cout<<"Invalid station! ";

}

else{

break;

}

case 2:

cout<<"Enter your station(1-6) ";

cin>>station;

if(station>6){

cout<<"Invalid station! ";

}

else{

break;

}

case 3:

cout<<"Enter your station(1-4) ";

cin>>station;

if(station>4){

cout<<"Invalid station! ";

}

else{

break;

}

case 4:

cout<<"Enter your station(1-3) ";

cin>>station;

if(station>3){

cout<<"Invalid station! ";

}

else{

break;

}

}

}

void logoff(){

int id;

cout<<"Enter your User ID to logoff: ";

cin>>id;

cout<<endl;

}