• Home
  • Blog
  • Create two stacks and a queue to keep track of cars using a parking lot.

Create two stacks and a queue to keep track of cars using a parking lot.

0 comments

Overview

For this assignment, we will practice using stacks and queues. In this exercise, you will 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

FIU has opened a new valet parking lot next to the PC building that requires a special decal to park. As the developer, you can select the special decal and the program should ask the user what decal they have for the car. If the user does not have the correct parking decal to park in the lot, the driver should be told nicely that they do not have the correct permit to park in this lot. For the purposes of this program, we will assume that the user always tells the truth about the decal they have for their car.

The parking lot is a “last-in, first-out” stack. When parking a new 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 before allowing a new car to be entered. 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.

Write a program that models this behavior, using one stack representing the the parking lot and one stack representing 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. For example, if I am attempting to park my car I would enter my license plate as 0569. When I’m ready to retrieve my call, I would enter -0569. The positive number tells the program that I wish to park my car, prompting the program to ask me my decal type. The program should tell me if I have the correct decal and if there is room to park my car. If the stack representing the parking lot is full, my car should be added to the waiting queue.

If I remove my car by entering -0569, the next car in the queue should be parked before a new car can be entered unless the queue is empty. The status of the parking lot and the waiting queue after each operation is complete. The status includes the cars that are parked in the lot as well as the cars that are currently waiting in the queue to park.

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 after each car is entered. The program should also tell the user if they have a correct decal. If they do, the program should tell the driver if their car will be parked in the lot or if it must wait in the waiting queue for a space to become available. If they do not, the program should politely tell the user that they do not have the correct deal to part in this lot.

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

Once you have it working as expected upload the .java file to this assignment drop box. You must also submit a Word doc or text file containing the Java code. Assignments not containing both the Java code and the text or Word file will be assigned a 0 for a grade.

Rubric

Project 7 Rubric

Criteria Ratings Pts

This criterion is linked to a Learning OutcomeUtilize a stack representing the parking lot

10 pts

Full Marks

There is a stack representing the parking lot

5 pts

Partial Credit

The program stores the cars but does not utilize a stack

0 pts

No Marks

The program does not store cars in the parking lot

10 pts

This criterion is linked to a Learning OutcomeUtilize a stack representing the street

10 pts

Full Marks

The program stores the cars temporarily removed from the lot in a stack representing the street

5 pts

Partial Credit

The program stores the cars temporarily removed from the lot, but not in a stack

0 pts

No Marks

The program does not store cars temporarily removed from the lot

10 pts

This criterion is linked to a Learning OutcomeUtilize a queue to store the cars waiting to park

10 pts

Full Marks

The program utilizes a queue to store the cars waiting to park and automatically populates the parking lot stack from the waiting queue when there is an opening in the lot

5 pts

Partial Credit

The program stores the cars waiting to part in the lot, but does not utilize a queue or it does not automatically populate the parking lot stack when there is a opening in the lot

0 pts

No Marks

The program does not store cars waiting to park when the lot is full

10 pts

This criterion is linked to a Learning OutcomeCheck the parking decal type and politely tell the driver if they do not have the correct decal

10 pts

Full Marks

The program checks the parking decal type and politely tell the driver if they do not have the correct decal

5 pts

Partial Credit

The program checks the parking decal type but either does not tell the driver they do not have the correct decal or it does not prevent someone with an incorrect decal from parking

0 pts

No Marks

The program does not check to see if the driver has the correct type of decal

10 pts

This criterion is linked to a Learning OutcomeLimit the number of cars parking in the lot to a maximum of 20

10 pts

Full Marks

The parking lot stack is limited to 20 entries

0 pts

No Marks

The parking lot stack is not limited to 20

10 pts

This criterion is linked to a Learning OutcomeOutput includes the cars parked in the lot and any cars waiting in the queue to park after each operation

10 pts

Full Marks

Output includes the cars parked in the lot and any cars waiting in the queue to park after each operation

5 pts

Partial Credit

The output includes the cars parked in the lot or any cars waiting in the queue to park after each operation, but not both or it does not output after each operation

0 pts

No Marks

The output is not correct

10 pts

This criterion is linked to a Learning OutcomeHave an easy to understand user interface that allows the user to park a car or retrieve a parked car

10 pts

Full Marks

The program has an easy to understand user interface that allows the user to park a car and retrieve a parked car

5 pts

Partial Credit

The user interface is difficult to understand or does not allow the user to park or retrieve a car

0 pts

No Marks

The user interface is difficult to understand and does not allow the user to park or retrieve a car

10 pts

This criterion is linked to a Learning OutcomeCode compiles and runs without errors

5 pts

Full Marks

Code compiles and runs without errors

0 pts

No Marks

Code does not compile and is automatically assigned 0 points for the overall grade

5 pts

This criterion is linked to a Learning OutcomeCode is properly commented

10 pts

Full Marks

Code is properly commented including all required header information

5 pts

Partial Credit

Code has some of the required comments but is sparsely commented or missing the correct header information

0 pts

No Marks

Code is sparsely commented or not commented at all and is missing all or most of the correct header information

10 pts

This criterion is linked to a Learning OutcomeProgram is properly designed and uses whitespace effectively

15 pts

Full Marks

Program is properly designed and uses whitespace effectively

5 pts

Partial Credit

Program is not properly designed or it does not use whitespace effectively

0 pts

No Marks

Program is not properly designed and it does not use whitespace effectively

15 pts

Total Points: 100

About the Author

Follow me


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}