Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

WRITE IN JAVA : Create a class Country with following attributes: private String code; private String name; private String continent; private List cities; Create class

WRITE IN JAVA :

Create a class Country with following attributes:

private String code;

private String name;

private String continent;

private List cities;

Create class City with following attributes:

private int id;

private String name;

private int population;

private String countryCode;

Generate parametrized constructors and getters and setters for all classes

In the main method initialize list of countries with following example values:

Country name: Netherlands, Continent: Europe, County code: NLD

Cities:

City name: Amsterdam, City population: 731200

City name: Rotterdam, City population: 593321

City name: Haag, City population: 440900

***********************************************************************************

Country name: Germany, Continent: Europe, County code: DEU

Cities:

City name: Berlin, City population: 3386667

City name: Hamburg, City population: 1704735

City name: Munich, City population: 1194560

***********************************************************************************

Country name: United States, Continent: North America, County code: USA

Cities:

City name: New York, City population: 8008278

City name: Los Angeles, City population: 3694820

City name: Chicago, City population: 2896016

***********************************************************************************

Country name: Armenia, Continent: Asia, County code: ARM

Cities:

City name: Yerevan, City population: 1248700

***********************************************************************************

Country name: Argentina, Continent: South America, County code: ARG

Cities:

City name: Buenos Aires, City population: 2982146

***********************************************************************************

Country name: Brazil, Continent: South America, County code: BRA

Cities:

City name: Rio de Janeiro, City population: 5598953

Using java stream create a program that will:

print the countries' details as shown above

print all the continents (without duplicates)

print all the country names from North America and South America (only country titles, not the whole objects)

The output should look like this:

image text in transcribed

City name: Berlin, City population: 3386667 City name: Hamburg, City population: 1704735 City name: Munich, City population: 1194560 Country name: United States, Continent: North America, County code: USA Cities: City name: New York, City population: 8008278 City name: Los Angeles, City population: 3694820 City name: Chicago, City population: 2896016 Country name: Armenia, Continent: Asia, County code: ARM Cities: City name: Yerevan, City population: 1248700 Country name: Argentina, Continent: South America, County code: ARG Cities: City name: Buenos Aires, City population: 2982146 Country name: Brazil, Continent: South America, County code: BRA Cities: City name: Rio de Janeiro, City population: 5598953 Printing all distinct continents: Europe North America Asia South America Printing all countries in South America and North America [United States, Argentina, Brazil] Cities in USA have population of 14599114 citizens

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

Mysql Examples Explanations Explain Examples

Authors: Harry Baker ,Ray Yao

1st Edition

B0CQK9RN2J, 979-8872176237

More Books

Students also viewed these Databases questions

Question

=+a) What value represents the 40th percentile of these returns?

Answered: 1 week ago

Question

Given that Cos 0 3 QII for find the Stry Funchan

Answered: 1 week ago

Question

1. What are the peculiarities of viruses ?

Answered: 1 week ago

Question

Describe the menstrual cycle in a woman.

Answered: 1 week ago