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 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...

  • 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...

  • 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...

  • 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....

  • Please help, need to code for this business assignment using c++. Business Expense Reimbursements Calculator Probl...

    Please help, need to code for this business assignment using c++. Business Expense Reimbursements Calculator Problem statement: Business trip is part of the enterprise culture. Suppose a businessperson just completed a business trip for your company. Now, you are tasked to write a program that calculates and displays the total travel expenses, allowable expenses for the trip, and the excess that must be paid by the businessperson, if any The program should prompt the user for the following . The...

  • Objectives: 1. Use if, switch, and loop statements 2. Use input and output statements 3. Incorporate...

    Objectives: 1. Use if, switch, and loop statements 2. Use input and output statements 3. 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 ask you what time the car left the parking deck. You should then calculate the time that has passed between...

  • This is a c++ program. Use the description from Parking Ticket Simulator (listed below) as a basis, where you need to...

    This is a c++ program. Use the description from Parking Ticket Simulator (listed below) as a basis, where you need to create a Car class and Police Officer class, to create a new simulation. Write a simulation program (refer to the Bank Teller example listed below) that simulates cars entering a parking lot, paying for parking, and leaving the parking lot. The officer will randomly appear to survey the cars in the lot to ensure that no cars are parked...

  • Solve it for java Question Remember: You will need to read this assignment many times to...

    Solve it for java Question Remember: You will need to read this assignment many times to understand all the details of the you need to write. program Goal: The purp0se of this assignment is to write a Java program that models an elevator, where the elevator itself is a stack of people on the elevator and people wait in queues on each floor to get on the elevator. Scenario: A hospital in a block of old buildings has a nearly-antique...

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
ADVERTISEMENT