Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use Javal to write a program with classes Country, CountryCollection and TestCountryCollection that reads Country objects from an input file Class Country describes one country
Use Javal to write a program with classes Country, CountryCollection and TestCountryCollection that reads Country objects from an input file Class Country describes one country object and has variables: name and capital of string type and population of long type. In addition, class Country has methods: public String getName () public String getcapital //returns capital public boolean isarge () public double getPopulation //returns number of inhabitants (in millions) public String tostring) // returns name // returns true for above 50 million inhabitants else returns false // returns string with all country's data in one line // separated by tabs. Class CountryCollection has no instance variables and provides the following recursive methods. Each method accepts parameter list, which is array of countries, and parameter n, which is an actual number of countries in the list. public static String tostring (Country [] list, int n) //returns String of all countries // in the list, one country per row. Countries must be in same order as they appear in the original list. public static int countLargeCountries (Country] list, int n) //returns number of // large countries in the list public static Countrv smallestCountry(CountryI1 1list, int n) //returns country // with smallest population public static void printLargeCountries (Countrv list, int n) //prints all large // countries in the list. Countries must be printed in same order as they appear in the original list. and population in this order. The data for the first eight countries in the input file should be as given. Add additional four rows of countries of your choice USA Washington, D.C. 32617 France Paris 65.23 Slovenia Ljubljana 2.08 Slovakia Bratislava 5.44 Liechtenstein Vaduz 0.05 Monaco Monaco 0.04 Spain Madrid 46.42 Japan Tokyo 126.53 Do not forget to append throws OException to the main method header in the class TestCountryCollection. In addition, you have to provide the following import statements in order to input data from input file and use Scanner class: import ava-io. * ; import javautil
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