Question: import javax.swing.JOptionPane; import java.io . File; import java.io . FileNotFoundException; import java.util.Scanner; import java.text.ParseException; public class AlertProcessor { public static void main ( String [
import javax.swing.JOptionPane;
import java.ioFile;
import java.ioFileNotFoundException;
import java.util.Scanner;
import java.text.ParseException;
public class AlertProcessor
public static void mainString args
CountyList countyList new CountyList;
AlertList alertList new AlertList;
Populate county list
popCountyListcountyList;
Process alerts from file
processAlertsFromFilealertList countyList;
Sort alerts
alertList.sortAlerts;
Output alerts
showOutputInDialogalertList countyList;
Method to populate county list
private static void popCountyListCountyList countyList
try
File file new FileD:comp SecurityChecksrcfipsCountytxt;
Scanner scanner new Scannerfile;
while scannerhasNextLine
String line scanner.nextLine;
Split the line by comma to get FIPS code and county data
String parts line.split; Split only into two parts
if partslength
String countyFIPSCode partstrim;
String countyData partssplit; Split only into two parts
if countyDatalength
String countyName countyDatatrim;
int population Integer.parseIntcountyDatatrim;
County county new CountycountyFIPSCode population, countyName;
countyList.addCountycounty;
else
System.out.printlnInvalid data format: line;
else
System.out.printlnInvalid data format: line;
scanner.close;
catch FileNotFoundException e
eprintStackTrace;
Method to process alerts from file
private static void processAlertsFromFileAlertList alertList, CountyList countyList
try
File file new FileD:comp SecurityChecksrcalertstxt;
Scanner scanner new Scannerfile;
while scannerhasNextLine
String line scanner.nextLine;
String parts line.split;
try
Alert alert new Alertparts parts parts parts;
alertList.addAlertalert;
catch ParseException e
System.err.printlnFailed to parse alert: egetMessage;
scanner.close;
catch FileNotFoundException e
eprintStackTrace;
Method to output alerts
private static void showOutputInDialogAlertList alertList, CountyList countyList
StringBuilder output new StringBuilder;
for Alert alert : alertList.getAlerts
output.appendalertgenerateDescriptioncountyListappend
;
JOptionPane.showMessageDialognull output.toString "Alerts", JOptionPane.INFORMATIONMESSAGE;
Invalid data format: Wood County, WV
Invalid data format: Wyoming County, WV
Invalid data format: WISCONSIN
Invalid data format: Adams County, WI
Invalid data format: Ashland County, WI
Invalid data format: Barron County, WI
Invalid data format: Bayfield County, WI I need the code to read the fipsCounty correctly
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
