This is what I have, but it is not working. import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.Scanner; public class EventManager { public static...

This is what I have, but it is not working. import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.Scanner; public class EventManager { public static void main(String[] args) // TODO Auto-generated method stub String [][] data = new String [500][6]; if(args.length == 0) { System.out.println("ERROR: expecting a file name"); return; } String path = args[0]; int i = 0; Scanner scan = null; try { File f = new File(path); scan = new Scanner (f); while(scan.hasNextLine()) { String line = scan.nextLine(); //Split the record string on the comma String [] lineItems = line.split(","); //Now array studentInfo has all the information we need. data[i][0] = lineItems[0]; data[i][1] = lineItems[1]; data[i][2] = lineItems[2]; data[i][3] = lineItems[3]; data[i][4] = lineItems[4]; data[i][5] = lineItems[5]; i++; } }catch(FileNotFoundException ex) { System.out.println("File Not Found"); } finally { if(scan!=null); scan.close(); } } { Scanner scan = new Scanner(System.in); while(true) { System.out.println("Search by event type (-t type) or district (-d code) (or q to quit): "); String userEntry = scan.nextLine(); if(userEntry.equalsIgnoreCase("q")) { System.out.println("Thank you for using our program."); break; } String flag = userEntry.substring(0, 2); if(flag.equals("-t")) { String [][] data = new String [500][6]; String query = userEntry.substring(2); query = query.trim(); System.out.println(query); int count = 0; for(int i = 0; i if(data[i][1].equalsIgnoreCase(query)) { count++; System.out.println("Number of events having type -d:"+count); } } } else if(flag.equals("-d")) { String [][] data = new String [500][6]; String query = userEntry.substring(0, 2); query = query.trim(); System.out.println(query); int count = 0; for(int i = 0; i if(data[i][4].equalsIgnoreCase(query)) { count++; System.out.println("Number of events having type -d:"+count); } else { System.out.println("Invalid entry: expecting –t type or –d code") } } } } } }
May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here