TreeMap Accumulating Tutorial

From Progzoo
Jump to navigation Jump to search

We process the world TreeMap in order to answer important questions.

Old Europe.

Prior to 2004 the members of the European Union were

Austria Belgium Denmark Finland France Germany Greece Ireland Italy Luxembourg The Netherlands Portugal Spain Sweden United Kingdom

Use an accumulating parameter to calculate the total area of old Europe.

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

New Europe.

In 2004 the following ten countries joined the EU

Cyprus, Czech Republic, Estonia, Hungary, Latvia, Lithuania, Malta, Poland, Slovakia, Slovenia

Calculate the total area of Europe including new and old.

String [] newEU = { "Cyprus",
"Czech Republic", "Estonia", "Malta",
"Hungary", "Latvia", "Lithuania",
"Poland", "Slovakia", "Slovenia"};
[Font] [Default] [Show] [Resize] [History] [Profile]

Old and New Europe.

Calculate the percentage of Europe that is old or new. Do this for area, population and GDP.

This is a debugging exercise. Most of the program is correct but there a couple of mistakes in the given answer.

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


The G8 summit in 2005 included Canada, France, Germany, Italy, Japan, Russia, United Kingdom and USA.

Calculate the total GDP for these countries and the total GDP for the planet. Print the GDP of the G8 as a percentage of World GDP.

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

Guessing the median population.

We speculate that Mauritania has the median population. If that is the case then the number of countries with a population higher is exactly the same as the number of countries with a smaller population.

Print the number of countries smaller and the number of countries bigger than Mauritania. Do not count countries with exactly the same population.

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