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

A Gentle Introduction to
Programming

Tutorial: Creating a TreeMap

 

We create our own TreeMap objects.

You may want to review the following before attempting these questions

1. Print every region once


Big

To print each region we must create our own list regionList. As we process each country we add the region to our list. The value we put in does not matter, we can use anything. Some regions will be added many times - this doesn't matter each simply over-writes the previous.

Print each region just once.

Hint:

2. The number of regions.


Big

Print the number of regions.

How big is a TreeMap?

3. Number of countries in each region.


Big

The program shown creates a new TreeMap called rList - we put in every region of the world.

Print the number of countries in each region. Use 35 characters for the region and 3 characters for the number.

4. Number of large countries in each region.


Big

For each region show the number of countries with a population of at least 10 million.

5. Number of large regions.


Big

Print region and total population for those regions with a total population of at least 100 million.

Use 35 characters for the region name and 13 characters for the total population.