Parking Garage Assignment Help ASAP Please

Hello I need some help please, I've been trying to get this to work for days now and it doesn't seem to work and I would appreciate if someone could fix the code for me so that the program works please as this was supposed to be a work for 4 people but my "friends" abandoned me at the last second and now I have to do a 4 -man assignment work and I'm really starting to lose hope since it's not working as expected and I only have till tomorrow to have it fixed,

Check the assignment(what the teacher wants us to do) here: http://i.imgur.com/Jn0hvWM.png

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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
  #include <iostream>
using namespace std;

int main()
{
	int restart;
	int duty;
	int userTime = 0;
	int a[2][15];
	int b[2][10];
	int c[2][5];
	int parkingPlace1 = 0;
	int parkingPlace2 = 0;
	int rejected = 0;
	int availableSpots = 0;
	int parking1 = 0;
	int parking2 = 0;
	int parking3 = 0;
	bool parked = false;

	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 15; j++) {
			a[i][j] = 0;
		}
	}
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 10; j++) {
			b[i][j] = 0;
		}
	}

	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 5; j++) {
			c[i][j] = 0;
		}
	}
	{
		do {
			int n = 0;
			parking1 = 0;
			parking2 = 0;
			parking3 = 0;
			cout << "Please specify your duty: \n1-Staff Member \n2-Faculty Member \n3-Student";
			cin >> duty;
			if (duty == 1) {
				for (int i = 0; i < 2; i++) {
					for (int j = 0; j < 15; j++) {
						if (userTime == 10 && i == 0) {
							if (a[i][j] == 0) {
								a[i][j] = 1;
								parkingPlace1 = i;
								parkingPlace2 = j;
								parked = true;
								break;
							}
							else {
								rejected = rejected + i;
							}
						}
						else if (i != 0) {
							if (a[i][j] == 0) {
								a[i][j] = 1;
								parkingPlace1 = i;
								parkingPlace2 = j;
								parked = true;
								break;
							}
							else {
								rejected = rejected + 1;
							}
						}
					}
					if (parked == true) {
						break;
					}
				}
				if (parked == false)
				{
					for (int i = 0; i < 2; i++) {
						for (int j = 0; j < 10; j++)
							if (userTime == 10 && i == 0) {
								if (b[i][j] == 0) {
									b[i][j] = 1;
									parkingPlace1 = i;
									parkingPlace2 = j;
									parked = true;
									break;
								}
								else {
									rejected = rejected + 1;
								}
							}
							else if (i != 0) {
								if (b[i][j] == 0) {
									b[i][j] = 1;
									parkingPlace1 = i;
									parkingPlace2 = j;
									parked = true;
									break;
								}
								else {
									rejected = rejected + 1;
								}

							}

							if (parked == true) {
								break;
							}
					}
				}
			}
			if (parked == false)
			{
				for (int i = 0; i < 2; i++) {
					for (int j = 0; j < 10; j++) {
						if (b[i][j] == 0) {
							b[i][j] = 1;
							parkingPlace1 = i;
							parkingPlace2 = j;
							parked = true;
							break;
						}
						else {
							rejected = rejected + 1;
						}
					}
					if (parked == true) {
						break;
					}
				}
			}
			if (parked == false)
			{
				for (int i = 0; i < 2; i++) {
					for (int j = 0; j < 5; j++) {
						if (c[i][j] == 0) {
							c[i][j] = 1;
							parkingPlace1 = i;
							parkingPlace2 = j;
							parked = true;
							break;
						}
						else {
							rejected = rejected + 1;
						}
					}
					if (parked == true) {
						break;
					}
				}
			}
			else if (duty == 3) {
				for (int i = 1; i < 2; i++) {
					for (int j = 0; j < 1; j++) {
						if (a[i][j] == 0) {
							a[i][j] = 1;
							parkingPlace1 = i;
							parkingPlace2 = j;
							parked = true;
							break;
						}
						else {
							rejected = rejected + 1;
						}
						if (parked == false)
						{
							for (int i = 0; i < 2; i++) {
								for (int j = 0; j < 5; j++) {
									if (userTime == 10 && i == 0) {
										if (c[i][j] == 0) {
											c[i][j] = 1;
											parkingPlace1 = i;
											parkingPlace2 = j;
											parked = true;
											break;
										}
										else {
											rejected = rejected + 1;
										}
									}
									else if (i != 0) {
										if (c[i][j] == 0) {
											c[i][j] = 1;
											parkingPlace1 = i;
											parkingPlace2 = j;
											parked = true;
											break;
										}
										else {
											rejected = rejected + 1;
										}
									}
								}
								if (parked == true) {
									break;
								}
							}
						}
					}
				}
			}
			else if (duty == 2) {
				for (int i = 0; i < 2; i++) {
					for (int j = 0; j < 1; j++) {
						if (a[i][j] == 0) {
							a[i][j] = 1;
							parkingPlace1 = i;
							parkingPlace2 = j;
							parked = true;
							break;
						}
						else {
							rejected = rejected + 1;
						}
					}
					if (parked == true) {
						break;
					}

					if (parked == true) {
						break;
					}
				}
				if (parked == false)
				{
					for (int i = 1; i < 2; i++) {
						for (int j = 0; j < 1; j++) {
							if (b[i][j] == 0) {
								b[i][j] = 1;
								parkingPlace1 = i;
								parkingPlace2 = j;
								parked = true;
								break;
							}
							else {
								rejected = rejected + 1;
							}
						}
						if (parked == true) {
							break;
						}
					}
				}
				if (parked == false)
				{
					for (int i = 1; i < 2; i++) {
						for (int j = 0; j < 5; j++) {
							if (c[i][j] == 0) {
								c[i][j] = 1;
								parkingPlace1 = i;
								parkingPlace2 = j;
								parked = true;
								break;
							}
							else {
								rejected = rejected + 1;
							}
						}
						if (parked == true) {
							break;
						}
					}
				}
			}
			else {
				cout << "Invalid Choice";
			}
			cout << "You parked at position: ";
			cout << "parkingPlace1";
			cout << "-";
			cout << parkingPlace2 << endl;
			cout << "Number of rejected spot: " << rejected << endl;
			rejected = 0;
			availableSpots = 0;
			for (int i = 0; i < 2; i++) {
				for (int j = 0; j < 15; j++) {
					if (a[i][j] == 0) {
						availableSpots = availableSpots + 1;
					}
					else {
						parking1 = parking1 + 1;
					}
					cout << a[i][j];
					cout << "-";
				}
				cout << endl;
				cout << endl;
			}
			for (int i = 0; i < 2; i++) {
				for (int j = 0; j < 10; j++) {
					if (b[i][j] == 0) {
						availableSpots = availableSpots + 1;
					}
					else {
						parking2 = parking2 + 1;
					}
					cout << b[i][j];
					cout << "-";
				}
				cout << endl;
				cout << endl;
			}
			for (int i = 0; i < 2; i++) {
				for (int j = 0; j < 5; j++) {
					if (c[i][j] == 0) {
						availableSpots = availableSpots + 1;
					}
					else {
						parking3 = parking3 + 1;
					}
					cout << c[i][j];
					cout << "-";
				}
				cout << endl;
				cout << endl;
			}
			cout << "Number of available spots: " << availableSpots << endl;
			cout << "Parking 1 parked spots: " << parking1 << endl;
			cout << "Parking 2 parked spots: " << parking2 << endl;
			cout << "Parking 3 parked spots: " << parking3 << endl;
			cout << "Sorry you cannot park since all the spots are full at " << userTime << endl;
			cout << "Would you like to restart? Press 1 to restart | Press 2 to exit program";
			cin >> restart;
		} while (restart == 1 );
		system("PAUSE");
		return 0;
	}
}



Tell your professor immediately that your friends have abandoned their part. I'll look at the code and get back to you.
Have you learned about functions? The code can be greatly simplified if you can use functions.

Have you learned about vectors?
You have been using array's. I think that is a good solution.

When I read this the first thing that springs to my mind is vectors. These vectors than need to be filled with more than one element. Therefor I would use struct.

If you would decide to go that route it would mean that you need to rewrite the whole thing.
How much time do you still have?

If you still have the weekend and want to impress your prof. try to see if you can solve this with class; structure and vector. I can't work the whole program out right now but what I have been thinking is here in a rough lay out.

I hope it helps.

in pseudo code:
class parking{
private:
struct spot {
int column;
int row;
float TimeLeave;
}
public:
float TimeIn;
float TimeLeave;

//member functions go here

};

int main(){
vector<spot> carspot;
carspot.clear();

//to fill the vector with struct elements use the following pseudo code.
for (int = 0 ; i < .......; i++){
spot.pusch_back()
spot.column.at(i) =
spot.row.at(i) =
spot.TimeLeave.at(i) =
}

//to read the vector you can use iterator. That is in pseudo code.
for (vector<spot>::const_iterator i = spot.begin(); i != spot.end(); i++){
i->column;
i->row;
i->TimeLeave;
}

return 0;
}


Last edited on
Is the assignment perfectly clear for you? It seems my English is even worst I supposed to be...

The first part (“The first parking (B- biggest parking area) can accomodate 15 cars in a column...”) seems to indicate a ‘normal’ fixed length array, but later it says: “Each parking has the same number of rows per column”.
Ok, so, now... it could be a multi-dimensional array, but this last sentence means:
a) all the three parkings have the same numbers of rows (so, if first parking has 3 rows, also the second and the third must have 3 rows)...
b) or: the three multidimensional arrays are ‘squared’ arrays (--> the first one 15x15, the second one 10x10, the third one 5x5)?

And: in the first case, is up to who writes the code to decide the number or rows?

Later: “...will ask the user if he would like to park in a coulmn reserved for a cars that leave at a later time”.
Why cars that leave at a later time? The only explanation seems to be that if a new car is parked in that column, than it prevent the others from exiting. Doesn’t it?
But now the exercise looks like it’s asking for stack management (first in, last out), which can be done with arrays, of course, but they won’t be my first choice. What’s more, I’ve never heard of a multidimensional stack...

BTW, Johnnyab, you don’t take advantage of any std container in your code... Are there restrictions about them?
Have you already worked on time management? I can’t see, in your code, how you manage the time.

However... good luck!

Guys please someone help me get this written, I can only use arrays functions and that simple stuff, we didn't learn strings and structures and that kind of stuff yet
I have less than 7 hours at the time making this post to present the project I'm totally screwed unless someone can write this for me please guys I'm trying to learn but I got screwed over by my so called friends and now I will fail the semester if I fail in this project

This is the assignment: http://i.imgur.com/gK8Z78W.png
"I have less than 7 hours at the time making this post to present the project I'm totally screwed unless someone can write this for me please guys I'm trying to learn but I got screwed over by my so called friends and now I will fail the semester if I fail in this project"

If you haven't addressed this until less than 7 hours before the project is due and you only address it by asking people you don't know to help you cheat, failing at this project seems like the thing that should happen.
there are two more functions to complete
1.make reservation
2.display board

good luck and dont include your friends ;)
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
#include<iostream>
#include<iomanip>
#include<string>
#include<cstdlib>
using namespace std;

//functions for the system
void displayStats(char lg[][15],char med[][10],char sm[][5],int trackTime1[],int trackTime2[],int trackTime3[]);
void displayParkingSlots(char lg[][15],char med[][10],char sm[][5]);

//basic functions to condense the amount of code
char validateSlot(char userData[]);
bool strcmp(char[],char[],int);
bool isFull(char **);

//initializes the parking lots
void initializeSlotsL(char[][15]);
void initializeSlotsM(char[][10]);
void initializeSlotsS(char[][5]);

//moves user and updates the time
void moveUserLargeSlot(char[][15],int userTime,int time[]);
void moveUserMediumSlot(char[][10],int userTime,int time[]);
void moveUserSmallSlot(char[][5],int userTime,int time[]);

//returns total cars park at specified slots
int totalParkSmall(char[][5]);
int totalParkMedium(char[][10]);
int totalParkLarge(char[][15]);

//displays a table of number of users parked by hour
void totalCarsParkedByHour(int hour,int lg[][15],int med[][10],int sm[][5]);

//returns the number of parking slots availabe
int numberOfParkingSlotsAva(char lg[][15],char med[][10],char sm[][5]);

void makeReservation();

int main()
{
    const int large = 15;
    const int medium = 10;
    const int small = 5;
/*
 * WARNING * THIS IS FOR MY VERSION OF THE PROJECT *****########
 * 
    int totalSpace;
    char *ROLE[] = {"staff","faculty","student"};//used to identify the person
    char Person_ID;//person identification, determines the persons position at the university
*/
    char slot[medium];
    //keeps track of time
    int timeTrackSmall[small * small] = {0};
    int timeTrackMedium[medium * medium] = {0};
    int timeTrackLarge[large * large] = {0};

    //creates parking slots
    char largeSlot[large][large];
    char mediumSlot[medium][medium];
    char smallSlot[small][small];
    //initializes the slots
    initializeSlotsL(largeSlot);
    initializeSlotsM(mediumSlot);
    initializeSlotsS(smallSlot);

    int time;

    //cout << "Enter your position at the school eg.(staff,faculty,student): ";

    cout << "Enter the amount of time you will park at the slot: ";
    cin >> time;

    while( time > 12 || time <= 0)
    {
        cout << "INVALID TIME, PLEASE RE-ENTER: ";
        cin >> time;
    }

    cout << "Enter the parking slot you would like to park in (large,medium,small): ";
    cin >> setw(10) >> slot;
    char t;
    t = validateSlot(slot);

    while( t == 'X' )
    {
        cout << "invalid slot. Enter the parking slot you would like to park in (large,medium,small): ";
        cin >> setw(10) >> slot;
        t = validateSlot(slot);
    }
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
bool check = true;

     if(t == 's')
    {
        for(int row = 0 ; row < small; row++)
        {
            for(int col = 0 ; col < small; col++)
                if(smallSlot[row][col] == 'X')
                {
                    check = false;
                    break;
                }
            if(check == false)
                break;
        }
        if(check == false)
        {
            moveUserSmallSlot(smallSlot,time,timeTrackSmall);
            cout<<"user move successful to large parking lot";
        }
    }
     if(t == 'm')
    {
        for(int row = 0 ; row < medium; row++)
        {
            for(int col = 0 ; col < medium; col++)
                if(mediumSlot[row][col] == 'X')
                {
                    check = false;
                    break;
                }
            if(check == false)
                break;
        }
        if(check == false)
        {
            moveUserMediumSlot(mediumSlot,time,timeTrackMedium);
            cout<<"user move successful to large parking lot";
        }
    }
     if(t == 'l')
    {
        for(int row = 0 ; row < large; row++)
        {
            for(int col = 0 ; col < large; col++)
                if(largeSlot[row][col] == 'X')
                {
                    check = false;
                    break;
                }
            if(check == false)
                break;
        }
        if(check == false)
        {
            moveUserLargeSlot(largeSlot,time,timeTrackLarge);
            cout<<"user move successful to large parking lot";
        }
    }

     char ans;

     if(check == true)
    {
        cout << "The selected slot was full. Would you like to move to another parking slot? type 'y' for yes and 'n' for no: ";
        cin >> ans;
        if(ans == 'y')
        {
            //check if slot is full to give user parking spot
            for(int row = 0 ; row < medium; row++)
            {
                for(int col = 0 ; col < medium; col++)
                    if(mediumSlot[row][col] == 'X')
                    {
                        check = false;
                        break;
                    }
                if(check == false)
                    break;
            }
            if(check == false)//lets the user park if parking mediumSlot is not full
            {
                moveUserMediumSlot(mediumSlot,time,timeTrackMedium);
                cout<<"User moved successful to medium parking lot";
            }
            else if( check == true)
            {
                cout << "The selected slot was full. Would you like to move to another parking slot? type 'y' for yes and 'n' for no: ";
                cin >> ans;
                if(ans == 'y')
                {
                    for(int row = 0 ; row < small; row++)
                    {
                        for(int col = 0 ; col < small; col++)
                            if(smallSlot[row][col] == 'X')
                            {
                                check = false;
                                break;
                            }
                        if(check == false)
                            break;
                    }
                    if(check == false)//lets the user park if parking mediumSlot is not full
                    {
                        moveUserSmallSlot(smallSlot,time,timeTrackSmall);
                        cout<<"user move successful to small parking lot!";
                    }

                }
            }
            else
            {
                cout << "All parking lots are full. Would you like to make a reservation for a parking lot? (y or n): ";
                cin >> ans;
                if(ans == 'y' || ans == 'Y')
                {
                   // makeReservation();//tells the user what size parking lot and the time he must go to park
                    /*  optional
                    displayStats();
                    displayParkingSlots();
                    */
                }
            }

        }
Last edited on
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
if( ans == 'n')
        {
            cout << "Would you like to make a reservation instead? (y or n): ";
            cin >> ans;
            if(ans == 'y')
            {
               // makeReservation();
                /*  optional
                displayStats();
                displayParkingSlots();
                */
            }
        }
    }
        displayStats(largeSlot,mediumSlot,smallSlot,timeTrackLarge,timeTrackMedium,timeTrackSmall);
    return 0;
}

//Code for functions
char validateSlot(char userData[])
{
    char s[] = "small";
    char m[] = "medium";
    char l[] = "large";

    if(strcmp(s,userData,15))
        return 's';
    else if(strcmp(m,userData,15))
        return 'm';
    else if(strcmp(l,userData,15))
        return 'l';
    return 'X';
}

bool strcmp(char a[],char b[],int size)
{
    for(int i = 0 ; i < size && b[i] != '\0'; i++)
        if(a[i] != b[i])
            return false;
    return true;
}

bool isFull(char **slot,int size)
{
    for(int row = 0 ; row < size; row++)
        for(int col = 0 ; col < size; col++)
            if(slot[row][col] == 'X')
                return false;
    return true;
}

void initializeSlotsL(char slot[][15])
{
    for(int row = 0 ; row < 15; row++)
        for(int col = 0 ; col < 15; col++)
            slot[row][col] = 'X';
}

void initializeSlotsS(char slot[][5])
{
    for(int row = 0 ; row < 5; row++)
        for(int col = 0 ; col < 5; col++)
            slot[row][col] = 'X';
}

void initializeSlotsM(char slot[][10])
{
    for(int row = 0 ; row < 10; row++)
        for(int col = 0 ; col < 10; col++)
            slot[row][col] = 'X';
}

void moveUserLargeSlot(char large[][15],int userTime,int time[])
{
    bool val = true;
    for(int row = 0; row < 5; row++)
    {
        for(int col = 0; col < 5; col++)
            if(large[row][col] == 'X')
            {
                large[row][col] = 'O';
                val = false;
                break;
            }
        if(val == false)
            break;
    }
    const int size = 15 * 15;
    for(int index = 0; index < size; index++)
        if(time[index] == 0)
        {
            time[index] = userTime;
            break;
        }
}

void moveUserMediumSlot(char medium[][10],int userTime,int time[])
{
    bool val = true;
    for(int row = 0; row < 5; row++)
    {
        for(int col = 0; col < 5; col++)
            if(medium[row][col] == 'X')
            {
                medium[row][col] = 'O';
                val = false;
                break;
            }
        if(val == false)
            break;
    }
    const int size = 10 * 10;
    for(int index = 0; index < size; index++)
        if(time[index] == 0)
        {
            time[index] = userTime;
            break;
        }
}

void moveUserSmallSlot(char small[][5],int userTime,int time[])
{
    bool val = true;
    for(int row = 0; row < 5; row++)
    {
        for(int col = 0; col < 5; col++)
            if(small[row][col] == 'X')
            {
                small[row][col] = 'O';
                val = false;
                break;
            }
        if(val == false)
            break;
    }
    const int size = 5 * 5;
    for(int index = 0; index < size; index++)
        if(time[index] == 0)
        {
            time[index] = userTime;
            break;
        }
}

int totalParkSmall(char sm[][5])
{
    const int size = 5;
    int counter = 0;
    for(int row = 0 ; row < size; row++)
        for(int col = 0; col < size; col++)
            if(sm[row][col] == 'O')
                counter++;
    return counter;
}

int totalParkMedium(char med[][10])
{
    const int size = 10;
    int counter = 0;
    for(int row = 0 ; row < size; row++)
        for(int col = 0; col < size; col++)
            if(med[row][col] == 'O')
                counter++;
    return counter;
}

int totalParkLarge(char lg[][15])
{
    const int size = 15;
    int counter = 0;
    for(int row = 0 ; row < size; row++)
        for(int col = 0; col < size; col++)
            if(lg[row][col] == 'O')
                counter++;
    return counter;
}

void displayStats(char lg[][15],char med[][10],char sm[][5],int trackTime1[],int trackTime2[],int trackTime3[])
{
    int totalCars1 = totalParkLarge(lg);
    int totalCars2 = totalParkMedium(med) ;
    int totalCars3 = totalParkSmall(sm);
    int totalSlotsRemaining = numberOfParkingSlotsAva(lg,med,sm);
    cout << "\nTotal cars parked at large parking lot: " << totalCars1 << endl
         << "Total cars parked at medium parking lot: " << totalCars2 <<endl
         << "Total cars parked at small parking lot: " << totalCars3 << endl
         << "Total number of parking slots remaining: " << totalSlotsRemaining << endl;

    int counter = 0;
    int hourTable[12] = {0};
    const int l = 15;
    const int m = 10;
    const int s = 5;
    int hour = 1;
    while(hour <= 12)
    {
        for(int i = 0; i < l; i++)
            if(trackTime1[i] == hour)
                counter++;
        for(int i = 0; i < m; i++)
            if(trackTime2[i] == hour)
                counter++;
        for(int i = 0; i < s; i++)
            if(trackTime3[i] == hour)
                counter++;
        hourTable[hour] = counter;
        counter = 0;
        hour++;
    }

    cout << endl << setw(15) << "Parking by Hour\n";
    for(int i = 0 ; i < 18; i++)
        cout<<"-";

    cout << endl << "|  Hours  |  Users |"<<endl;
    for(int i = 0 ; i < 18; i++)
        cout<<"-";
    cout <<endl;
    for(int i = 1 ; i < 13 ; i++)
    {
        cout<<"|   "<< i <<"   |   " << hourTable[i] << "   |"<<endl;
        for(int i = 0 ; i < 18; i++)
            cout<<"-";
        cout<<endl;
    }


}

int numberOfParkingSlotsAva(char lg[][15],char med[][10],char sm[][5])
{
    int counter = 0;

    const int l = 15;
    const int m = 10;
    const int s = 5;

    for(int row = 0 ; row < l; row++)
        for(int col = 0; col < l; col++)
            if(lg[row][col] == 'X')
                counter++;
    for(int row = 0 ; row < m; row++)
        for(int col = 0; col < m; col++)
            if(med[row][col] == 'X')
                counter++;

    for(int row = 0 ; row < s; row++)
        for(int col = 0; col < s; col++)
            if(sm[row][col] == 'X')
                counter++;
    return counter;
}

void displayParkingSlots(char lg[][15],char med[][10],char sm[][5])
{
    
}
i had fun doing it XD and thanks for uploading the project it helped me as well ;)
By the way to make it run over and over you must implement a do while loop in the main example
1
2
3
4
5
6
7
8
int char an;
do
{
//..... some the code given in main
cout << "would you like to exit (y or n): ";
cin >> an;

}while(an == 'y');
Last edited on
Omg kanata1!!
Thanks so, so much man but there's an issue!
I didn't really learn "strings" or "iomanip" can you or anyone who reads this post please try to make the code a bit more basic now that we have something?? I'm soo grateful for this I really appreciate it man omg

Last edited on

just delete the libraries #include<string> and #include<iomanip> and go through the code and delete the setw() function this function only format the text when it outputs it should not affect the functionality of the program only the way it looks on the screen. you can delete the #include<string> i just placed it there for my personal use

Your welcome
Last edited on
Topic archived. No new replies allowed.