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

A Gentle Introduction to
Java Programming

Tutorial: Adding values

 

1. Total area


Big

Calculate the total area of the world.

This time we add to the accumulator each time. We can use either of the statements below:

acc = acc + area;
acc += area;

2. Total population


Big

Calculate the total population of the world.

The answer - at a little over 6 billion will be too large for and int. Use a long instead.

3. Total GDP of Africa


Big

Calculate the total GDP of the countries of Africa.

4. Total GDP of the 'West'.


Big

Calculate the total GDP of the western world. Include the regions "North America", "Europe" and "Oceania" as the western world.