Question: USING JAVA In this Program we are going to build a Country class and load in data from a File into a Single ArrayLists of
USING JAVA


In this Program we are going to build a Country class and load in data from a File into a Single ArrayLists of Countries. We are going to be reading in these entries and we can ignore all the countries where either the name or the city is two names. Feel free to programmatically do this by using a Try/Catch block or by finding the 3rd "" and seeing if the next digit is a number or by deleting these rows. The Countries-populations.txt contains a list of countries of the world and their populations. Each line in the files contains information for one country, the country's name, the country's capital, area in square miles and population. Your driver program that has the main will be called CountryInfo. Input data from the file: 1) Read the lines in the file countries-populations.txt and determine the number of lines (number of countries) in the file. 2) Using a while loop, fill in the country with the values read from the files. 3) Sort the array list of countryNames alphabetically and print the first 10 Countries with their Name, Capital, Area and Population. 4) Sort the Array List by Population. Display the first 10 biggest countries. Display 10 smallest. Your Country class will have a public String toString(){ } method that will use String.format() to print the country details in column format. See 4.3 String.format and printf for how to complete this. 5) Sort the ArrayList by Population per square mile. List first 10. On your Country Method. Have 3 Constructors. Use "this" to overload them. Create a public int population Per Mile(){ Create a public String toString() to return a Column Formatted String So all Country Names, City Names Align Left, Numbers align Right Sample Output Countries of the World X, XXX, XXX Average Population Size: Average Size in Sq Miles: First 10 countries Country Capital Area Sq Miles Population Afghanistan Albania Algeria Kabul Tirani Algiers 250,000 11,100 919,590 31,056,997 3,581,655 32,930,091 Extra Country Details Requested
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
