Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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. (b) Ask the user to select an attribute (name of the country, population, or population grow rate) on which the list is to be sorted. (c) Sort the list based on the users choice using the sort method in MyUtil. Do not use any sort method provided in Java API. (d) Display the list before and after sorting. The display must show one country per line (i.e. do not display all countries on one line).

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

Logidata+ Deductive Databases With Complex Objects Lncs 701

Authors: Paolo Atzeni

1st Edition

354056974X, 978-3540569749

More Books

Students also viewed these Databases questions

Question

e. What are notable achievements of the group?

Answered: 1 week ago