Question: Fix following code by the following the requirements below. Use the setup code as your source. The objective is to program a two stack and
Fix following code by the following the requirements below. Use the setup code as your source. The objective is to program a two stack and queue method.?
import java.util.LinkedList;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
import java.util.Stack;
public class Main {
public static
int numOfSpots = 15; // number of spots in the parkingLot
Stack
Stack
Queue
Scanner scan = new Scanner(System.in);
int licensePlate = scan.nextInt();
for (int i = 0; i < 10; i++) { // loop over with a sets conditions that 10 cars have already parked in the parkinglot
Car car = new Car();
System.out.println("Welcome to the FIU PC Parking Lot");
System.out.println(" ");
}
do while(licensePlate < numOfSpots) {
licensePlate = scan.nextInt();
System.out.println("Get Decal");
if (parkinglot.size() >= 15) {
waitingCars.add(licensePlate);
System.out.println("Parking lot is full. Car is added to queue.");
}
else
{
parkinglot.push(licensePlate);
String decal = generateRandomDecal(10000);
licensePlate.setDecal(licensePlate.generateRandomDecal);
System.out.println("You've parked your car at the PC building" + licensePlate);
}
scan.close();
}
}
}
I have inserted following following requirement
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.
- Generate a random decal type.
- 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 15.
- Populate the parking lot with 10 cars to start.
- 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.
Step by Step Solution
There are 3 Steps involved in it
import javautilLinkedList import javautilQueue import javautilRandom import javautilScanner import j... View full answer
Get step-by-step solutions from verified subject matter experts
