Question
The ?le (countryData.txt) contains data about countries, one country per line, starting with the name of a country followed by two numeric values (population in
The ?le (countryData.txt) contains data about countries, one country per line, starting with the name of a country followed by two numeric values (population in thousand and population annual growth rate (%)), delimited by tabs. Write a Java program to sort the countries on one of the three attributes selected by the user. Your program needs to include the following classes: 1. Country. Itcontainsappropriateinstancevariables(declaredasprivate),aparameterizedconstructor, access methods, and toString method. In addition, make sure there is a natural ordering de?ned for Country objects. Note that you need an internal variable indicating which attribute the user has selected as the sorting attribute. 2. MyUtil. It contains a generic method to sort a given list of type E, where objects of type E can be comparedaccordingtotheirnaturalordering. Themethodusesthebubblesort algorithmthatisgiven on the next page. 3. An application that does the following: (a) Read data from the ?le and store the information in a List
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