Tutorial/Accumulate/Adding Values-old

From Progzoo
Jump to: navigation, search

Total area

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;

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

Total population

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.

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

Total GDP of Africa

Calculate the total GDP of the countries of Africa.

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

Total GDP of the 'West'.

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

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