Zoo tutorials: [ SQL | Linux | XML ]
ProgZoo: [ Java | C# | VB | C++ | Perl ]
Log in

A Gentle Introduction to
Perl Programming

Tutorial: Accumulating values.

 

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

You will need the file world.dat to answer these questions offline.

1. Old Europe.


Big

Prior to 2004 the members of the European Union were

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

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

Array of old Europe
The answer

2. New Europe.


Big

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",
                   "Hungary", "Latvia", "Lithuania", "Malta",
                   "Poland", "Slovakia", "Slovenia"};

3. Old and New Europe.


Big

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.

Error one
Error two

4. G8


Big

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

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.

Percentages
G8 as a list

5. Guessing the median population.


Big

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.