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

The Knockemdead Parking Garage contains a single lane that holds up to four cars

ID: 3536728 • Letter: T

Question

The Knockemdead Parking Garage contains a single lane that holds up to four cars. Cars arrive at the south end of the garage and leave from the north end. If a customer arrives to pick up a car that is not the northernmost, all cars to the north of his car are moved out, his car is driven out, and the other cars are restored in the same order that they were in originally. Whenever a car leaves, all cars to the south are moved forward so that at all times all the empty spaces are in

the south part of the garage.


Write a program that reads a group of input lines. Each line contains an 'a' for arrival or a d' for departure and a license plate number. Cars are assumed to arrive and depart in the order

specified by the input. The program should print a message each time that a car arrives or departs. When a car arrives, the message should specify whether or not there is room in the garage for the car. If there is no room for a car, the car then proceeds to the Bashemup garage...which is similar to the Knockemdead.


There is room for 4 cars at the Bashemup Garage. Now...if both garages are filled up, cars wait in the street near the Knockemdead garage for a space..and of course they are queued up in the street as well. The street can hold only 4 cars. If more than 4 cars try to wait in the street the cars are told to go to BOSTON.


So in summary...when a car arrives it tries to park in the Knockemdead

If no room it goes to the Bashemup...If still no room it tries to park in the street

INDICATE BY MESSAGE WHERE A CAR GOES WHEN IT ARRIVES

When a car departs a message should indicate where it departed from (i.e. which

garage or the street).

If there is a car waiting to get in the garage (because both are full) then the first car in the street queue must be moved into the garage that now has room and a message stating this must appear.


When a car exits either garage (but NOT the street) the parking fee must be also be displayed as follows:

If the car is at the front of the queue when about to depart fee is $ 10

If the car is second in the queue the fee is $15

If the car is 3rd or 4th the fee is $ 25

No fee for departing from street

The possibility also exists that the car you are looking for is not there!!

Hey this is the BIG APPLE!

First try it with integers then try strings


When we exit the program it should indicate how many cars are in each garage and the street and the total of the fees collected (based on which cars departed)


const int maxqueuechar = 20;

class queuechar_type // declaration of class//

{

public:

void clear_queuechar(); //member functions//

bool empty_queuechar(); // of class queue_type//

bool full_queuechar();

void insert_queuechar(char ch);

void delete_queuechar(char& ch);

char queuechar[21];

int frontch,rearch;

};


void queuechar_type::clear_queuechar()

{

frontch = maxqueuechar;

rearch = maxqueuechar;

}

//----------------------------------------------------------------------

bool queuechar_type::empty_queuechar()

{

if (rearch == frontch)

return true;

else

return false;

}

//----------------------------------------------------------------------

bool queuechar_type::full_queuechar()

{

int querear;

if (rearch == maxqueuechar)

querear = 0;

else

querear = rearch + 1;

if (querear == frontch)

return true;

else

return false;

}

//----------------------------------------------------------------------

void queuechar_type::insert_queuechar(char ch)

{

if (rearch == maxqueuechar)

rearch = 0;

else

rearch = rearch + 1;

queuechar[rearch] = ch;

}

//----------------------------------------------------------------------

void queuechar_type::delete_queuechar(char& ch)

{

if (frontch == maxqueuechar)

frontch = 0;

else

frontch = frontch + 1;

ch = queuechar[frontch];

}

Explanation / Answer

FOLLOW THIS


ANSWER


pseudo code:-
car arrive
yes:
lot full?
yes:
put car in wait queue
no:
put car in lot queue
car depart
yes:
car in lot queue?
yes:
car in front of queue?
yes:
remove car from front of lot queue
move rest of cars up
any car in wait queue?
yes:
put front car in lot queue
move cars up in wait queue
no:
loop1:
put front car in hold stack
car in front of lot?
no:
go to loop1
yes:
remove car from front of lot queue
move rest of cars up
any car in wait queue?
yes:
put front car in lot queue
move cars up in wait queue
pop cars from hold stack put them back in queue
move cars in queue up 1
any car in wait queue?
yes:
put front car in lot queue
move cars up in wait queue
no:
car in front of wait lot?
yes:
loop2:
put front car in hold stack
car in front of wait lot?
no:
go to loop2
yes:
remove car from front of wait queue
move rest of cars up
pop cars from hold stack put them back in wait lot
move cars in lot up 1

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