Question

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

PC1 Free PC2 Free PC3 Free PC4 ack PC5 Free PC6 Free PC7 Mary PC8 Free PC9 Free PC10 Alice Lab 1 PC1 Lab 2 PC2 John PC3 Free PC4 Free PC5 Mike PC6 Free Free PC1 Free PC2 Free PC3 Free Lab 3 PC1 Free PC3 Free PC4 Free PC6 Free PC7 Free PC11 PC2 Tom PC5 Tim PC8 Free PC9 Jimm PC10 Kate PC12 Free Lab 4 Free

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)Add N new computers to a lab.

: 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).

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 log in to computer 3 in 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.

there should be two ways to logout.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#include <iostream>
 
#include <string>
 
#include <vector>
 
#include <algorithm>
 
using namespace std;
 
vector<vector<string> > computerLabs(4);
 
int sizes[4];
 
void initialize()
 
{
 
computerLabs[0].resize(10, "");
 
computerLabs[1].resize(6, "");
 
computerLabs[2].resize(3, "");
 
computerLabs[3].resize(12, "");
 
sizes[0] = 10;
 
sizes[1] = 6;
 
sizes[2] = 3;
 
sizes[3] = 12;
 
}
 
void print()
 
{
 
for(int i=0; i<4; i++){
 
cout << "Lab " << i+1 << ": ";
 
for(int j=0; j<sizes[i]; j++){
 
cout << "PC" << j+1 << ": ";
 
if(computerLabs[i][j] == "") cout << "Free ";
 
else cout << computerLabs[i][j] << " ";
 
}
 
cout << endl;
 
}
 
}
 
int main()
 
{
 
int choice, c, lab, fl = 1;
 
string name;
 
initialize();
 
cout << "Choose option:" << endl;
 
cout << "1. Print current status of computers in all labs" << endl;
 
cout << "2. Login in a lab" << endl;
 
cout << "3. Logout of a computer" << endl;
 
cout << "4. Exit" << endl;
 
cout << "5. Add N Computers to a lab" << endl;
 
while(1){
 
cout << "Enter choice: ";
 
cin >> choice;
 
switch(choice){
 
case 1: print();
 
break;
 
case 2: cout << "Enter name: ";
 
cin >> name;
 
cout << "Enter Lab number: ";
 
cin >> lab;
 
cout << "Enter Computer number: ";
 
cin >> c;
 
if(computerLabs[lab-1][c-1] == ""){
 
computerLabs[lab-1][c-1] = name;
 
cout << "Logged in successfully" << endl;
 
}
 
else{
 
cout << "Computer is unavailable" << endl;
 
}
 
break;
 
case 3: cout << "Enter Lab number: ";
 
cin >> lab;
 
cout << "Enter Computer number: ";
 
cin >> c;
 
if(computerLabs[lab-1][c-1] == ""){
 
cout << "PC already free" << endl;
 
}
 
else{
 
computerLabs[lab-1][c-1] = "";
 
cout << "Logged out successfully" << endl;
 
}
 
break;
 
case 4: fl = 0;
 
break;
 
case 5: cout << "Enter Lab number: ";
 
cin >> lab;
 
cout << "Enter Computers to add: ";
 
cin >> c;
 
sizes[lab-1] += c;
 
computerLabs[lab-1].resize(sizes[lab-1]);
 
cout << "New PCs added" << endl;
 
break;
 
default: cout << "Incorrect Choice" << endl;
 
break;
 
}
 
if(fl == 0) break;
 
}
 
return 0;
 
}
Add a comment
Know the answer?
Add Answer to:
In this assignment, you will implement a simple version of Computer Lab administration system in C++....
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
  • 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...

  • 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...

  • 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)...

  • 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...

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

    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 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...

  • 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...

  • Introduction: In this lab, you will write a MIPS program to read in (up to) 50...

    Introduction: In this lab, you will write a MIPS program to read in (up to) 50 integer values from the user, store them in an array, print out the amay, one number per line, reverse the elements in the array and finally print out the elements in the just-reversed) array. Feel free to do this lab and all assembly programming labs) in Windows. You must use MARS Getting started: l. In MARS, create a new assembly file with the name...

  • Write in C Spring 2016 Lab Assignment 11 ET2100 In computer programming in general a "string"...

    Write in C Spring 2016 Lab Assignment 11 ET2100 In computer programming in general a "string" is a sequence of characters. In the C language anything within double quotes is a "string constant" so you have been seeing strings all semester. But we can also have string variables. In the C language these are implemented as an array of char, e.g. char name (10]: In order to make these variables easier to work with, it has been universally agreed that...

  • In C++ Assignment 8 - Test Scores Be sure to read through Chapter 10 before starting this assignment. Your job is to write a program to process test scores for a class. Input Data You will input a tes...

    In C++ Assignment 8 - Test Scores Be sure to read through Chapter 10 before starting this assignment. Your job is to write a program to process test scores for a class. Input Data You will input a test grade (integer value) for each student in a class. Validation Tests are graded on a 100 point scale with a 5 point bonus question. So a valid grade should be 0 through 105, inclusive. Processing Your program should work for any...

  • IN C++ ADD COMMENTS AS MUCH AS POSSIBLE Exercise 1: Duplicate the Arrays Suppose you are...

    IN C++ ADD COMMENTS AS MUCH AS POSSIBLE Exercise 1: Duplicate the Arrays Suppose you are developing a program that works with arrays of integers, and you find that you frequently need to duplicate the arrays. Rather than rewriting the array-duplicating code each time you need it, you decide to write a function that accepts an array and its size as arguments. Creates a new array that is a copy of the argument array, and returns a pointer to the...

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