C#:Formatting Numbers Tutorial

From Progzoo
Jump to: navigation, search

A floating point number includes a decimal point for example:

3.1
3.1415f

You might want to look at the following before tackling these questions:

Population in millions to one decimal place

For the countries of South America, show the name, the population, and the population in millions to one decimal place.

Example:

Argentina             39,300,000    39.3
[Font] [Default] [Show] [Resize] [History] [Profile]

Area

For the countries of South America show the name and the area in thousands of square kilometers to two decimal places.

Use 20 character spaces for the name and 10 for the area. Use commas for the area format.

Example:

Peru                  1,285.22
[Font] [Default] [Show] [Resize] [History] [Profile]

per Captia GDP

Show the name of the country and the per capita gdp for countries of Asia.

Use 20 character spaces for the name and 10 for the per capita GDP. Show the per capita GDP to two decimal places. The values are in US dollars, so include the $ sign right after the name.

Example:

India               $   3072.40
[Font] [Default] [Show] [Resize] [History] [Profile]

Richer countries

The per capita GDP of the UK is a little more than $29,000

Show the name and GDP of those countries with a per capita GDP of more than 29000

Use 25 character spaces for the name and 10 for the per capita GDP. Show the per capita GDP to two decimal places. The values are in US dollars, so include the $ sign right after the name.

Example:

United Kingdom                $ 29,483.08
[Font] [Default] [Show] [Resize] [History] [Profile]