By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,388 Members | 1,770 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,388 IT Pros & Developers. It's quick & easy.

C++ queues and parking lots

P: 1
I have this homework and all help will be apreciated

The Putdentsinem Parking Garage contains a single lane that
holds up to 7 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 northenmost, 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. You should TRY to use strings as license plate numbers but if you have difficulty use integers!
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 Knockemdead garage...which is similar to the
Putdentsinem. There is room for 7 cars at the Knockemdead garage.
Now...if both garages are filled up, cars wait in the street
near the Putdentsinem garage for a space..and of course they are queued
up in the street. The size of the street queue is also 7. I will
not allow more than 21 cars total so don't worry about overflow
on the street!

So in summary...when a car arrives it tries to park in the Putdentsinem garage.
If no room it goes to the Knockemdead...a message indicates which garage
it is in.....When a car departs a message indicates that a car has departed
and also indicates which garage...

Now here is the challenge...when a car departs you should also
indicate what the parking fee is how it works
If a car is at the front of the queue, the charge is $ 2.00
If a car is second in the queue (that is you need to move one
car out of the way) the charge is $ 3.00
If a car is third in the queue the charge is $ 4.00
get the idea??? Note: If a car departs from the street there is
of course no charge. Also if both garages are full and a car
departs from either garage, the car in front of the street queue moves
Mar 14 '07 #1
Share this Question
Share on Google+
2 Replies

P: 1,646
Hi. It is a good idea to read the posting guidelines particularly with regard to assignments before asking a question.

After you read them, I am assuming that you have not, you should return and ask your question because there does not appear to be one in your post.
Mar 14 '07 #2

Expert Mod 5K+
P: 8,916
Also if you had read those guidelines you would know we do not allow the posting of full source on coursework assignments. When you have worked out what you want to ask you may back it up with a code snippet (that is a section of code but not the entire source).
Mar 14 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.