computer science

CSCI 3000 Homework 4

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 a sample state of the system:

Lab Array

Some of the computers are free (no one logged in), and some others are occupied by students.

In the implementation, you will define a Lab array (an array of string pointers) in the stack memory. This pointer array can be local to the main function or it can be a global. And each pointer in the array will point to a string array that is dynamically allocated from the heap memory. (Size of each array is given above)

Initially, all computers in all labs will be set to “Free” state. Then you will provide a menu to the user such as

1)    Print the current status of computers in all labs

2)    Log in a new student to a computer in a lab

a.     Ask user name, the lab number, and the computer number. If it is available, log that student in.

3)    Log out a student from his/her computer in a lab

a.     Ask user the lab number and the computer number. If the computer is occupied, log that student out.

4)    Exit

5)    (Bonus Option +20 Points) Add N new computers to a lab.

Note: Here you will ask user the lab number and the how many new computers (N) to add. Then you will add those computers to the lab without losing the current content (logged in students).

(Tip: You will allocate a new array space (with N more elements) from the heap, then move the content of the old array to the new array. Finally, you will send the address of the new array to corresponding lab pointer. All new elements (computers) will be set to “Free” state.



Example Case for Menu option 2:

If the current state of the labs as given in first figure, and if a new student “Kim” wants to login computer 3 of Lab 3, you will update the corresponding element in the correct array by writing students name. The new state of the labs will be

Another example would be logging out a student from the computers. In that case, the student name will be replaced with the word “Free” in the array.


On the top of your source code, please add your name and number, Course ID, HW number and the date using a comment block. Please see the example below,


Your Name – Your number

CSCI 3000, HW-X

(Due Date)


Please do not copy your code from someone else’s program. The instructor may use a code comparison program that automatically checks the similarity between different programs. And do not hesitate to contact me if you are having trouble with the homework. I will be more than happy t