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

Java programming assignment: USER INPUT IS IN BOLD You run four computer labs. E

ID: 3701831 • Letter: J

Question

Java programming assignment:
USER INPUT IS IN BOLD

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) as input data. Similarly, when a user logs off a station, your system receives the Lab Number and computer station number.
Write a Java 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 Number Computer Stations
1 1: empty 2: empty 3: empty 4: empty 5: empty
2   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
Task:-
1. 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 table should be updated.
2. Write a search option so the administrator can type in a user Id and the system will output what Lab Number and station number the 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 Output:- (User input is in bold and Italics)
STATUS Lab # Computer Stations 1 1: empty 2: empty 3: empty 4: empty 5: empty 2 1: empty 2: empty 3: empty 4: empty 5: empty 6: empty 3 1: empty 2: empty 3: empty 4: empty 4 1: empty 2: empty 3: empty
MAIN MENU 0) Exit 1) login 2) logoff 3) Lookup 1 Input 5 digit ID of the user you want to find: 12345 Input lab #(1-4): 2 Input station # (1-6): 3
STATUS Lab number CS 1 1: empty 2: empty 3: empty 4: empty 5: empty 2 1: empty 2: empty 3: 12345 4: empty 5: empty 6: empty 3 1: empty 2: empty 3: empty 4: empty 4 1: empty 2: empty 3: empty
MAIN MENU 0) Exit 1) login 2) logoff 3) Lookup 2 Input 5 digit ID of the user you want to find: 12345 User 12345 is logged off.
STATUS Lab number CS 1 1: empty 2: empty 3: empty 4: empty 5: empty 2 1: empty 2: empty 3: empty 4: empty 5: empty 6: empty 3 1: empty 2: empty 3: empty 4: empty 4 1: empty 2: empty 3: empty
MENU 0) Exit 1) login 2) logoff 3) Lookup

Explanation / Answer

import java.io.*;

import java.util.*;

public class b

{

public static void disp(int[][] a)

{

int ic=0,jc=0;

String s="";

System.out.println(" ");

for(int i[]:a)

{

System.out.print("Lab : "+(ic+1)+"--> ");

for(int j:i)

{

if(j==0)s="empty";

else s=""+j;

System.out.print(""+(jc+1)+" : "+s+" ");

jc++;

}

System.out.println();

jc=0;ic++;

}

}

public static void main(String[] arg)

{

Scanner sc=new Scanner(System.in);

int choice=0;

int id=0,station=0,lab=0,ic=0,jc=0;

int flag=0;

//lab computers allocation

int[][] lc=new int[4][];

lc[0]=new int[5];

lc[1]=new int[6];

lc[2]=new int[4];

lc[3]=new int[3];

do

{

System.out.println("Menu : 0)Exit 1)Login 2)Logoff 3)LookUp ");

System.out.print("Enter your choice : ");

choice=sc.nextInt();

switch(choice)

{

case 1://login

System.out.print("Enter ID : ");

id=sc.nextInt();

System.out.print("Enter Station number : ");

station=sc.nextInt();

System.out.print("Enter Lab number : ");

lab=sc.nextInt();

lc[lab-1][station-1]=id;

disp(lc);

break;

case 2://logoff

System.out.print("Enter Station number : ");

station=sc.nextInt();

System.out.print("Enter Lab number : ");

lab=sc.nextInt();

lc[lab-1][station-1]=0;

disp(lc);

break;

case 3://lookup

System.out.print("Enter ID : ");

id=sc.nextInt();

flag=0;ic=0;jc=0;

for(int[] i:lc)

{

for(int j:i)

{

if(j==id)

{

System.out.println("User :" +id+" is logged in Lab : "+(ic+1)+" Station : "+(jc+1)+" ");

flag=1;

break;

}

jc++;

}

jc=0;

ic++;

}

break;

default:

choice=0;

break;

}

}while(choice!=0);

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote