Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago