Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer question 3 and it should be written in Java, and here is the Country class as well as the .csv file. private String

image text in transcribed

Please answer question 3 and it should be written in Java, and here is the Country class as well as the .csv file.

 private String name; private String code; private String capitol; private int happinessRank; private double population; private double GDP; public Country(String name,String code,String capitol,double population,double gdp,int hr) { this.name=name; this.code=code; this.capitol=capitol; this.population=population; GDP=gdp; happinessRank=hr; } public String getCapitol() { return capitol; } public void setCapitol(String capitol) { this.capitol = capitol; } public double getPopulation() { return population; } public void setPopulation(int population) { this.population = population; } public int getHappinessRank() { return happinessRank; } public void setHappinessRank(int happinessRank) { this.happinessRank = happinessRank; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public double getGDP() { return GDP; } public void setGDP(double gDP) { GDP = gDP; } @Override public String toString() { return name+","+code+","+capitol+","+population+","+GDP+","+happinessRank; } @Override public int compareTo(Country arg0) { if (this == arg0) return 0; return this.name.compareTo(arg0.name); } }
Country Name Country Code Capitol City Population GDP Happiness Rank
South Korea KOR Seoul 51709098 2.24E+12 55
Hong Kong of China HKG Hong Kong 7451000 3.63E+11 71
Azerbaijan AZE Baku 9942334 4.69E+10 85
Thailand THA Bangkok 69428524 5.05E+11 32
Cyprus CYP Nicosia 1189265 2.45E+10 65
Saudi Arabia SAU Riyadh 33699947 7.82E+11 37
Malawi MWI Lilongwe 18143315 7.06E+09 136
Nigeria NGA Abuja 1.96E+08 3.97E+11 95
Rwanda RWA Kigali 12301939 9.51E+09 151
Angola AGO Luanda 30809762 1.06E+11 140
Ivory Coast CIV Yamoussoukro 23740424 1.06E+11 128
Sweden SWE Stockholm 10183175 5.51E+11 9
Zambia ZMB Lusaka 17351822 2.67E+10 116
Benin BEN Porto-Novo 11485048 1.04E+10 143
Sri Lanka LKA Colombo 21670000 8.89E+10 120
Lebanon LBN Beirut 6848925 5.66E+10 88
Kyrgyz Republic KGZ Bishkek 6315800 8.09E+09 98
Iceland ISL Reykjavik 353574 2.59E+10 3
Gabon GAB Libreville 2119275 1.7E+10 118
1. Reuse your Country class from Project 1 (correct it if necessary) 2. Create a class named Stack that will implement a stack of country objects using an array. Support the following methods. a. Constructor that creates the stack array based on a size provided. b. A push method to push a country on the stack. c. A pop method to pop a country off the stack and return it. d. A printStack method to print the stack from top down to bottom of it. e. An isEmpty method that returns true if the stack is empty, false otherwise f. An is Full method that returns true if the stack is full, false otherwise 3. Create a class named Priority that implements a priority queue of country objects using a sorted array, based on GDP per capita, the higher the GDP per capita, the higher the priority. Support the following methods: a. Constructor that creates the stack array based on a size provided. b. An insert method to insert a country into the queue. (This should be an O(N) method.) c. A remove method to remove a country from the front of the queue and return it. (This should be an O(1) method.) d. A printQueue method to print the queue in priority order. e. An isEmpty method that returns true if the priority queue is empty, false otherwise f. An is Full method that returns true if the priority queue is full, false otherwise 4. Create a class named Project2 that will: a. Let us define five groups of countries based on GDP per capita: POOR countries as those with GDP per capita

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

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions

Question

=+Could you use an ambient ad?

Answered: 1 week ago