Question: Hi, I'm trying to write code for the following instructions and my current code is giving me the an error with opening the file that
Hi, I'm trying to write code for the following instructions and my current code is giving me the an error with opening the file that contains the code. I am not sure what I'm doing wrong. I'm new to java. Can you help me through this. The txt file I am trying to open contains information in the second picuture.


Sample output should be:
All cars:
Make = GM Year = 2014 Price = 20000
Make = Honda Year = 2014 Price = 18000
Make = Hyundai Year = 2020 Price = 25000
All cars made by Honda
Make = Honda Year = 2014 Price = 18000
All cars made after 2016
Make = Hyundai Year = 2020 Price = 25000
public class Car { private String make; private int year; private int price; public Car() { }
public Car(String make, int year, int price) { this.make = make; this.year = year; this.price = price; } public String getMake() { return make; } public int getYear() { return year; } public int getPrice() { return price; } public void setMake(String make) { this.make = make ; } public void setYear(int year){ this.year = year; } public void setPrice(int price){ this.price = price; } public String toString() { String c = "\tMake = " + make + "\tYear = " + year + "\tPrice = " + price; return c; }
}
Your program must have three methods findByMake, newerThan, and main methods. findByMake method Signature public static void findByMake (Car[] cars, String make) Behavior Receives an array of Car objects and the make of a car make. Finds and prints all cars in the array that have the same make as the given make. Prints an appropriate message, if there is no car with the given make. No return value. newerThan method Signature: public static void newer Than(Car[] cars, int year) Behavior Receives an array of Car objects and the year of a car year. Finds and prints all cars in the array that are newer than the given year (in other words, the cars made later than the given year). Prints an appropriate message, if there is no car newer than the given year. No return value main method The program must read information about cars from an input file named car inputl.txt. In the input file, the first line has the number of cars in the file. The subsequent lines have car information, one car in each line. An example input is shown below: 8 GM, 20000, 2014 Honda, 18000, 2014 Hyundai, 25000, 2020 Kia, 15000, 2010 Ford, 35000, 2021 Toyota, 30000, 2020 Ford, 17000, 2010 Honda, 20000, 2016
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
