The population density of a region is the ratio of its population to its area. For example, in the 1990 census, the total resident population of the state of Iowa was 2802944, and the land area of the state is 55965 square miles; so its 1990 population density was 2802944/55965 persons per square mile.
The file exercise-9.dat contains a list of Iowa's ninety-nine counties, giving the name, 1990 population, and land area in square miles of each county. A typical line of the file looks like this:
Poweshiek 19018 586
On each line, columns 1 through 13 contain the county name, left-justified; columns 14 through 16 are blank; columns 17 through 22 contain the population, right-justified; columns 23 through 25 are blank; and columns 26 through 28 contain the area in square miles.
The exercise is to write a program that will read from this data file and write out (to standard output) a list of all the counties in Iowa, sorted by population density, from greatest to least. For each county, write out its name and population density; use the inexact-number format and print exactly one place after the decimal point. A typical line of output might therefore look like this:
Poweshiek 32.4
This document is available on the World Wide Web as
http://www.math.grin.edu/courses/Scheme/fall-1997/exercise-9.html
created December 5, 1997
last revised December 5, 1997