Question
Java Create a new Eclipse project and place the file KansasSortedCities.csv into the root folder. Note that on a Windows machine, one can right-click and
Java
Create a new Eclipse project and place the file KansasSortedCities.csv into the root folder. Note that on a Windows machine, one can right-click and open this file in notepad to see the contents. If one double-clicks on a .csv file, it will likely default to opening in Excel.
KansasSortedCities.csv (partially shown) Abbyville,88 Abilene,6590 Ada,53 . . . Yoder,269 Zenda,88 Zurich,99
Write code that adheres to the following outline: o Open the KansasSortedCites.csv file. If the file does not exist, display an error message that states KansasSortedCites.csv does not exist. Then exit the program with a status of 1. You may not hardcode the file name into the error message; rather use the getName() method from the File object. o Use a loop to continue reading while there is more information in the file.
As the loop cycles through all cities in the file, it will keep track of the largest city and its population. o It will also tally the total population. o Helpful code in this loop will be: String cityInfo = input.nextLine(); String[] cityInfoArray = cityInfo.split(","); After those two lines execute, cityInfoArray[0] will contain the city name, and cityInfoArray[1] will contain the population. You will need to use Integer.parseInt on cityInfoArray[1] to extract the integer for use in mathematical calculation. o (Hint: as you are building the code, you could initially display each city and its population and/or step through with a debugger.) o After the loop, display the results. This will be the output to match: Total Population: 2,422,545 Largest City: Wichita (388,413) Utilize the Decimal Format class to automatically produce the commas in the output. See the notes examples for currency in chapter 05. The pattern to use for Decimal Format is #,###. o Optionally, you may also include additional statistics such as the smallest city, average population, total number of cities, etc. ? You must include internal documentation to describe chunks of code and also include your name as @author for the class. ? Your program should be generic enough to also run if there were other states with files of the same format.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started