In this assignment, you will need to design and implement a class Country (Country.java) that stores the name of the country, its population, and its area. Then write a program (LargestCountry.java) that reads countries from a “coutrydata.txt” and prints • The country with the largest area. • The country with the largest population. • The country with the largest population density (people per square mile). To make it concrete, the followings are the suggested tasks you need to perform: 1.1 Country Class In the first file Country.java, create a class named Country that models a country. It should contain at least the followings (However, you can add any other methods if you like): • Private instance variables name, population, and area; • A constructor takes all three inputs (the name, population and area); • Three getter methods to return each of three instance variables (accessor method); • One getter method to return country population density (accessor method); • Three setter methods to change each of three instance variables (mutator); • A method printCountry that prints out the country information. 1 1.2 LargestCountry Class In the second file LargestCountry.java, you are required to write methods for reading country data, and finding required information. The followings are suggested methods that you need to implement: • Method 1: readCountry /** Reads a country in from a file. @return all countries in an arraylist */ public static ArrayList readCountry(String fileName) throws FileNotFoundException { // your work here } • Method 2: countryWithLargestArea /** @return the country with the largest area */ public static Country countryWithLargestArea( ArrayList countries) { // your work } • Method 3: countryWithLargestPopulation /** @return the country with the largest population */ public static Country countryWithLargestPopulation( ArrayList countries) { // your work } • Method 4: countryWithLargestPopulationDensity /** @return the country with the largest population density */ public static Country countryWithLargestPopulationDensity( ArrayList countries) { // your work } 2 In your main() method in LargestCountry.java, you will use the methods you have implemented to do the following: (1) Read the “coutrydata.txt” in; (2) Print out your findings (See a sample output in Figure 1).

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

In this assignment, you will need to design and implement a class Country (Country.java) that stores the name of the country, its population, and its area. Then write a program (LargestCountry.java) that reads countries from a “coutrydata.txt” and prints • The country with the largest area. • The country with the largest population. • The country with the largest population density (people per square mile). To make it concrete, the followings are the suggested tasks you need to perform: 1.1 Country Class In the first file Country.java, create a class named Country that models a country. It should contain at least the followings (However, you can add any other methods if you like): • Private instance variables name, population, and area; • A constructor takes all three inputs (the name, population and area); • Three getter methods to return each of three instance variables (accessor method); • One getter method to return country population density (accessor method); • Three setter methods to change each of three instance variables (mutator); • A method printCountry that prints out the country information. 1 1.2 LargestCountry Class In the second file LargestCountry.java, you are required to write methods for reading country data, and finding required information. The followings are suggested methods that you need to implement: • Method 1: readCountry /** Reads a country in from a file. @return all countries in an arraylist */ public static ArrayList readCountry(String fileName) throws FileNotFoundException { // your work here } • Method 2: countryWithLargestArea /** @return the country with the largest area */ public static Country countryWithLargestArea( ArrayList countries) { // your work } • Method 3: countryWithLargestPopulation /** @return the country with the largest population */ public static Country countryWithLargestPopulation( ArrayList countries) { // your work } • Method 4: countryWithLargestPopulationDensity /** @return the country with the largest population density */ public static Country countryWithLargestPopulationDensity( ArrayList countries) { // your work } 2 In your main() method in LargestCountry.java, you will use the methods you have implemented to do the following: (1) Read the “coutrydata.txt” in; (2) Print out your findings (See a sample output in Figure 1).

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 7 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education