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

A Gentle Introduction to
C# Programming

Tutorial: Introducing Country

 

In these tutorials we introduce the class Country. An object of the Country class has five fields: name region area pop gdp

The Country class is defined in Country.cs The fields are:
public String name;
public String region;
public int area;
public long pop;
public long gdp;

1. GDP for Italy.


Big

The world structure includes all of the countries in our list. We can access a country by its name.

We can access the fields of a country using the dot notation.

Change the code so that it prints the gdp for Italy.

2. Area of Benelux.


Big

Print the combined area of Belgium, Netherlands and Luxembourg

3. How many times bigger.


Big

Print the population of China divided by the population of the United Kingdom.

This tells us how many times China is bigger than the United Kingdom.

4. France and Germany.


Big

Print the name, the population and the per capita GDP for France and for Germany.

Use 20 characters for the name, 12 for the population (include commas) and 8 for the per capita GDP.

Recall that the per capita GDP is the GDP divided by the population.