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

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

ID: 3625304 • Letter: T

Question

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.


Explanation / Answer

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

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