Question: In JAVA. My code ( listed below ) is giving me multiple errors in red ( code should be outputting information on the right )

In JAVA. My code (listed below) is giving me multiple errors in red (code should be outputting information on the right) and I do not know what I am doing wrong. We need to utilize one of these for our code bubble sort, selection sort, insertion sort, quicksort, sequential search, binary search iterative, binary search recursive, recursion. Question: Ask the user for a filename from one of the 4files listed: car-list-1.txt,car-list-2.txt,car-list-3.txt,car-list-4.txt. Display the oldest car for every manufacturer from that file. If two cars have the same year, compare based on the VIN. The 4 separate files each contain over 30,000 car information characters see below for example for one of files: make,model,year,vin
Chevrolet,Colorado,2009,WBAKE5C52BE206874
Buick,Century,1987,2G4WC582361806993
Dodge,Avenger,2000,WBAPM73549E332510
Dodge,Intrepid,2002,WAUGL78E95A466829
Hyundai,Tucson,2011,JN1CV6EK1DM713325
Acura,Vigor,1993,5LMJJ2H54CE009281
Plymouth,Grand Voyager,1992,5TFAW5F1XEX090336
Nissan,Pathfinder,2009,WBABD33414J659330
Lincoln,MKX,2013,WAUHF68P36A616863
Pontiac,Grand Prix,1975,1GYEC63897R284181
BMW,5 Series,2003,1HGCR6F34FA973569
Toyota,Camry Hybrid,2010,WA1DGAFE9DD829888
Ferrari,458 Italia,2010,5GNRNHEE2A8491279
Hummer,H1,1995,JHMGE8G30CC780839
Chevrolet,Silverado,2011,WBAPH73589A743078
Pontiac,Grand Prix,2002,19UYA42411A692063
Dodge,Caravan,2000,WAUBGAFB2AN313359
Hyundai,Elantra,2009,KMHTC6AD1EU115615
Bentley,Continental GT,2009,1GKS1CE09ER231633
GMC,Savana 2500,2000,WBADX1C54CJ285369
Plymouth,Laser,1992,JA32X8HW6AU507070
Hyundai,Excel,1992,KMHTC6AD8EU686485
Chrysler,Voyager,2001,1N4AL2APXBC442164
Audi,RS 6,2003,1G6AB5S32F0906777
Porsche,Boxster,2011,KL4CJESB7FB607963****MY CODE **** import java.io.*;
import java.util.*;
class Car {
String make;
String model;
int year;
String vin;
public Car(String make, String model, int year, String vin){
this.make = make;
this.model = model;
this.year = year;
this.vin = vin;
}
@Override
public String toString(){
return make +""+ model +""+ year +""+ vin;
}
}
public class SortCars {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
System.out.print("Enter filename: ");
String filename = scanner.nextLine();
List cars = readCarsFromFile(filename);
if (cars == null){
System.out.println("Error reading file. Exiting.");
return;
}
Map oldestCarsByMake = findOldestCarsByMake(cars);
System.out.println("Oldest cars by make:");
for (Car car : oldestCarsByMake.values()){
System.out.println(car);
}
}
private static List readCarsFromFile(String filename){
List cars = new ArrayList>();
try (BufferedReader br = new BufferedReader(new FileReader(filename))){
String line;
while ((line = br.readLine())!= null){
String[] parts = line.split("\\s+");
if (parts.length >=4){
String make = parts[0];
String model = parts[1];
int year = Integer.parseInt(parts[2]);
String vin = parts[3];
cars.add(new Car(make, model, year, vin));
}
}
} catch (IOException | NumberFormatException e){
e.printStackTrace();
return null;
}
return cars;
}
private static Map findOldestCarsByMake(List cars){
Map oldestCarsByMake = new HashMap>();
for (Car car : cars){
if (!oldestCarsByMake.containsKey(car.make)){
oldestCarsByMake.put(car.make, car);
} else {
Car existingCar = oldestCarsByMake.get(car.make);
if (car.year existingCar.year ||
(car.year == existingCar.year && car.vin.compareTo(existingCar.vin)0)){
oldestCarsByMake.put(car.make, car);
}
}
}
return oldestCarsByMake;
}}
In JAVA. My code ( listed below ) is giving me

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!