Question

The laughs parking garage contains a single lane that hold up to ten cars. Cars arrive...

The laughs parking garage contains a single lane that hold up to ten 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 northernmost, all the cars to the north of his car are moved out, his car is driven out, and the others cars are restored in the same order that they were in originally. Whenever a car leaves, all the cars to the south are moved forward. So that at all the times all the empty spaces are in the south part of the garage.
Write a Java program to reads a group of input lines. Each line contains an “a” arrival or a “d” 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 massage should specify whether or not there is room for the car in garage. If there is no room for a car, the car waits until there is room or until a departure line is read for the car. When room becomes available, another massage should be printed. When a car departs, the massage should include the number of times the car was moved within the garage (including the departure itself but not the arrival), this number is 0 if the car departs from the waiting line.


0 0
Add a comment Improve this question Transcribed image text
Answer #1

please rate - thanks

hope this is what you need

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

Add a comment
Know the answer?
Add Answer to:
The laughs parking garage contains a single lane that hold up to ten cars. Cars arrive...
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
  • The Parking Garage Problem

    The Scratchemup parking garage contains a single lane that holds up to 10 cars. Cars arrive at the south end of the garage and leave from the north end. If a customerarrives to pick up a car that is not the northernmost, all cars to the north of his car are moved out, her car is driven out, and the other cars are restored in thesame order that they were in originally. Whenever a car leaves, all cars to the...

  • The Bashemin Parking Garage contains a single lane that can hold up to ten cars. Arriving...

    The Bashemin Parking Garage contains a single lane that can hold up to ten cars. Arriving cars enter the garage at the rear and are parked in the empty space nearest to the front. Departing cars exit only from the front. If a customer needs to pick up a car that is not nearest to the exit, then all cars blocking its path are moved out temporarily, the customer's car is driven out, and the other cars are restored in...

  • The CSC326 parking garage contains 2 lanes, each capable of holding up to 10 cars. There...

    The CSC326 parking garage contains 2 lanes, each capable of holding up to 10 cars. There is only a single entrace/exit to the garage at one end of the lanes. If a customer arrives to pick up a car which is not nearest the exit, all cars blocking the car's path are moved into the other lane. If more cars still must be moved out of the way, they go into the street. When the customer's car is driven out,...

  • PLease, I need help with this Code. PLease create correctly documentations comments for better understanding. This...

    PLease, I need help with this Code. PLease create correctly documentations comments for better understanding. This is the input: JAV001 ARRIVE JAV002 ARRIVE JAV003 ARRIVE JAV004 ARRIVE JAV005 ARRIVE JAV001 DEPART JAV004 DEPART JAV006 ARRIVE JAV007 ARRIVE JAV008 ARRIVE JAV009 ARRIVE JAV010 ARRIVE JAV011 ARRIVE JAV012 ARRIVE JAV013 ARRIVE JAV014 ARRIVE JAV006 DEPART JAV014 DEPART JAV013 DEPART JAV005 DEPART JAV015 ARRIVE JAV010 DEPART JAV002 DEPART JAV015 DEPART JAV014 DEPART JAV009 DEPART JAV003 DEPART JAV008 DEPART JAV007 DEPART JAV012 DEPART JAV011...

  • A parking garage charges a $2.00 minimum fee to park for up to three hours. The...

    A parking garage charges a $2.00 minimum fee to park for up to three hours. The garage charges an additional $0.50 per hour in excess of these initial three hours. The maximum charge for any given 24 hour period is $10.00. Assume no car parks for longer than 24 hours at a time. Write a program that calculates and prints the total parking charges for the customers who parked their cars in this garage (at least 4 cars) and the...

  • Programming Assignment #2 (Arrays) I. The Assignment This assignment is to take your Garage class from...

    Programming Assignment #2 (Arrays) I. The Assignment This assignment is to take your Garage class from the previous assignment and modify it so that it uses an array of Car objects as the principal data structure instead of an ArrayList-of-Car. This is an example of the OOP principle of information hiding as your Car and test classes will not have to be modified at all. Unless you broke encapsulationon the previous assignment, that is   II. Specifications Specifications for all 3...

  • Write code for the following program in C. As per proper coding practice, plan out your...

    Write code for the following program in C. As per proper coding practice, plan out your program with psuedocode and include this before the main function. I visited Fields Museum in Chicago few months ago to look at Mummy’s. You have been asked to write a program that can be used to control the number of people who can be in the exhibition room at the same time. Groups of people can always leave the room (if they are inside),...

  • I need help in C++ . Project 3 – Parking Deck Ticketing System Objectives: Use if,...

    I need help in C++ . Project 3 – Parking Deck Ticketing System Objectives: Use if, switch, and loop statements to solve a problem. Use input and output statements to model a real world application Incorporate functions to divide the program into smaller segments Instructions: Your task is to write a program that simulates a parking meter within the parking deck. The program will start by reading in the time a car arrives in the parking deck. It will then...

  • This program will provide the user the tools to make up trains from a file of...

    This program will provide the user the tools to make up trains from a file of available cars. The car data will be the reporting identifier, car type, weight (in tons) and length (in feet) for each car. The user can select to make up a train by total weight, total length or car type. The user will be able to display any train’s consist, and will be able to delete a train (returning the cars to the pool of...

  • Overview: In this lab, you will write a program called JobScheduler; it should take a single...

    Overview: In this lab, you will write a program called JobScheduler; it should take a single input file as a command-line argument. Each line in the input file has the following format: <job #> <priority> <arrival time (sec)> <duration (sec)> e.g. a file might contain: 1 3 10 100 5 2 20 50 8 4 5 100 (all values will be positive integers) These jobs might represent computer programs (or threads) that need to be run by the operating system....

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