Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / For this example , we will practice using stacks and queues

For this example , we will practice using stacks and queues

Computer Science

For this example , we will practice using stacks and queues. Create two stacks and a queue to keep track of cars using a parking lot. We will use the nature of the stacks and queues to solve the problem.

Specifications

Rules

We have opened a new valet parking lot next to the Science building that requires a special decal to park. If the car does not have the correct parking decal, the driver should be told nicely that they do not have the correct permit to park in this lot.

The parking lot is a "last-in, first-out" stack. When parking a car, the program must first check to see if the car has the correct decal. If it does have the correct permit, the car may be added to the lot as long as there is enough room. To park a car, the car's license tag is added to the parking lot stack. The parking lot can hold 20 cars at a time. If the parking lot is full, a waiting car can be added to a waiting queue. When a car leaves the lot, the next car in the queue will be able to park in the parking lot. When a car owner retrieves a vehicle that wasn't the last one in, the cars blocking it must temporarily move to the street so that the requested vehicle can leave.

A program that models this behavior, using one stack for the driveway and one stack for the street. A queue will be used to store the cars waiting for a place to park of the lot is full

Use integers as license plate numbers. Positive numbers add a car, negative numbers remove a car, zero stops the simulation. If the stack representing the parking lot is full, the car waiting should be added to the queue. Print out the parking lot stack and the waiting queue after each operation is complete.

Expected Output:

The expected output should contain the list of cars currently parked in the parking lot and the list of cars currently waiting to park.

Java Requirements

The program must

  • Utilize a stack representing the parking lot.
  • Utilize a stack representing the street.
  • Utilize a queue to store the cars waiting to park.
  • Check the parking decal and politely tell the driver if they do not have the correct decal.
  • Limit the number of cars parking in the lot to a maximum of 20.
  • Output that includes the cars parked in the lot and any cars waiting in the queue to park after each operation.
  • Have an easy to understand user interface that allows the user to park a car or retrieve a parked car.

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE