Introducing Country Tutorial

From Progzoo
Jump to: navigation, search

In these tutorials we introduce the class Country. An object of the Country class has five fields: name region area pop gdp

We also introduce the TreeMap world - this represents all 262, it is indexed by name of the country.

GDP for Italy.

The TreeMap world allows us to access a country directly - we do not need to loop through them all.

Change the code so that it prints the gdp for Italy.

[Font] [Default] [Show] [Resize] [History] [Profile]

Area of Benelux.

Print the combined area of Belgium, The Netherlands, Luxembourg

[Font] [Default] [Show] [Resize] [History] [Profile]

How many times bigger.

Print the population of China divided by the population of the United Kingdom.

This tells us how many times China is bigger than the United Kingdom.

[Font] [Default] [Show] [Resize] [History] [Profile]

France and Germany.

Print the name, the population and the per capita GDP for France and for Germany.

Use 20 characters for the name, 12 for the population (include commas) and 8 for the per capita GDP.

Recall that the per capita GDP is the GDP divided by the population.

[Font] [Default] [Show] [Resize] [History] [Profile]