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 files listed: carlisttxtcarlisttxtcarlisttxtcarlisttxt Display the oldest car for every manufacturer from that file. If two cars have the same year, compare based on the VIN. The separate files each contain over car information characters see below for example for one of files: make,model,year,vin
Chevrolet,Colorado,WBAKECBE
Buick,Century,GWC
Dodge,Avenger,WBAPME
Dodge,Intrepid,WAUGLEA
Hyundai,Tucson,JNCVEKDM
Acura,Vigor,LMJJHCE
Plymouth,Grand Voyager,TFAWFXEX
Nissan,Pathfinder,WBABDJ
Lincoln,MKXWAUHFPA
Pontiac,Grand Prix,GYECR
BMW Series,HGCRFFA
Toyota,Camry Hybrid,WADGAFEDD
Ferrari, Italia,GNRNHEEA
Hummer,HJHMGEGCC
Chevrolet,Silverado,WBAPHA
Pontiac,Grand Prix,UYAA
Dodge,Caravan,WAUBGAFBAN
Hyundai,Elantra,KMHTCADEU
Bentley,Continental GTGKSCEER
GMCSavana WBADXCCJ
Plymouth,Laser,JAXHWAU
Hyundai,Excel,KMHTCADEU
Chrysler,Voyager,NALAPXBC
Audi,RS GABSF
Porsche,Boxster,KLCJESBFBMY CODE import java.io;
import java.util.;
class Car
String make;
String model;
int year;
String vin;
public CarString 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 mainString args
Scanner scanner new ScannerSystemin;
System.out.printEnter filename: ;
String filename scanner.nextLine;
List cars readCarsFromFilefilename;
if cars null
System.out.printlnError reading file. Exiting.";
return;
Map oldestCarsByMake findOldestCarsByMakecars;
System.out.printlnOldest cars by make:";
for Car car : oldestCarsByMake.values
System.out.printlncar;
private static List readCarsFromFileString filename
List cars new ArrayList;
try BufferedReader br new BufferedReadernew FileReaderfilename
String line;
while line brreadLine null
String parts line.splits;
if partslength
String make parts;
String model parts;
int year Integer.parseIntparts;
String vin parts;
cars.addnew Carmake model, year, vin;
catch IOException NumberFormatException e
eprintStackTrace;
return null;
return cars;
private static Map findOldestCarsByMakeList cars
Map oldestCarsByMake new HashMap;
for Car car : cars
if oldestCarsByMake.containsKeycarmake
oldestCarsByMake.putcarmake, car;
else
Car existingCar oldestCarsByMake.getcarmake;
if caryear existingCar.year
caryear existingCar.year && car.vin.compareToexistingCarvin
oldestCarsByMake.putcarmake, car;
return oldestCarsByMake;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
