how do i properly make a method that takes in a 1d array and prints out the
Question:
how do i properly make a method that takes in a 1d array and prints out the information in the 1d array that contains a name of a city, country, double oneWay, and double roundtrip.
This method receives all the Flights stored in a 1D array and displays them to the user.
public static void displayAvailableFlights(Flights[] f)throws Exception{
System.out.println("--------------------------[ Available Flights ] --------------------------");
System.out.println("| " + "CITY" + "t | " + "COUNTRY" + "t | "+ "ONE WAY" + "t | " + "ROUND TRIP" + " |");
//Read file for variable info
File myFile = new File("flights.csv");
Scanner fileReader = new Scanner(myFile);
while(fileReader.hasNextLine()){
String city = fileReader.next();
String country= fileReader.next();
double oneWay = fileReader.nextDouble();
double roundTrip = fileReader.nextDouble();
//Print info
System.out.println("|" + city + "t" + country + " | $" + oneWay + "t| $ " + roundTrip + "t| ");
System.out.println("----------------------------------------------------------------");
}
}