Finish the menu program(in the photo) connecting the methods in CarLot to the correct menu option. CartLot Program: import java.io.*; import java.util.*; public class CarLot { private ArrayList inventory; public CarLot() { inventory = new ArrayList<>(); } public ArrayList getInventory() { return inventory; } public void setInventory(ArrayList inventory) { this.inventory = inventory; } public Car findCarByIdentifier(String identifier) { for (Car car : inventory) { if (car.getId().equals(identifier)) { return car; } } return null; } public ArrayList getCarsInOrderOfEntry() { return new ArrayList<>(inventory); } public ArrayList getCarsSortedByMPG() { ArrayList sortedByMPG = new ArrayList<>(inventory); selectionSort(sortedByMPG); return sortedByMPG; } private void selectionSort(ArrayList sortedByMPG) { for (int i = 0; i < sortedByMPG.size() - 1; i++) { int minIndex = i; for (int j = i + 1; j < sortedByMPG.size(); j++) { if (sortedByMPG.get(j).getMPG() < sortedByMPG.get(minIndex).getMPG()) { minIndex = j; } } Car temp = sortedByMPG.get(minIndex); sortedByMPG.set(minIndex, sortedByMPG.get(i)); sortedByMPG.set(i, temp); } } public Car getCarWithBestMPG() { if (inventory.isEmpty()) { return null; } Car bestMPGCar = inventory.get(0); for (Car car : inventory) { if (car.getMPG() > bestMPGCar.getMPG()) { bestMPGCar = car; } } return bestMPGCar; } public Car getCarWithHighestMileage() { if (inventory.isEmpty()) { return null; } Car highestMileageCar = inventory.get(0); for (Car car : inventory) { if (car.getMileage() > highestMileageCar.getMileage()) { highestMileageCar = car; } } return highestMileageCar; } public double getAverageMpg() { if (inventory.isEmpty()) { return 0; } double totalMpg = 0; for (Car car : inventory) { totalMpg += car.getMPG(); } return totalMpg / inventory.size(); } public double getTotalProfit() { double totalProfit = 0; for (Car car : inventory) { totalProfit += car.getSalesPrice() - car.getCost(); } return totalProfit; } public void addCar(String id, int mileage, int mpg, double cost, double salesPrice) { inventory.add(new Car(id, mileage, mpg, cost, salesPrice)); } public void sellCar(String identifier, double priceSold) { Car car = findCarByIdentifier(identifier); if (car != null) { car.setSalesPrice(priceSold); } else { System.out.println("Car with identifier " + identifier + " not found."); } } public void saveToDisk() throws IOException { try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("carlot.dat"))) { out.writeObject(inventory); } } @SuppressWarnings("unchecked") public ArrayList loadFromDisk() throws IOException, ClassNotFoundException { try (ObjectInputStream in = new ObjectInputStream(new FileInputStream("carlot.dat"))) { inventory = (ArrayList) in.readObject(); } return inventory; } }
