IUP Computer Science
CO 300 Assembly Language
Fall 1987

Program #5 (due 23 November 1987


Write a program that can read in a series of ten city names and temperatures from the terminal, displays the city names in alphabetical order and the average temperature for the cities.

The city names and temperatures are entered in records of up to 50 characters. There is absolutely NO order to the data; that is, there may be a name then a temperature or two names then three or four temperatures or several temperatures and then some names (NO ORDER). The only guarantees are 1) each two data values that are in the same record are separated by at least one space or a comma or both, 2) no city name has any embedded spaces, any embedded commas or any embedded hyphens, and 3) there are no extra names or temperatures - just 10 of each.

The program should build an array of city names (allow up to 12 characters for each name) and a 2's complement array of WORDs to hold the temperatures. After building the arrays, the program should call a FORTRAN subroutine (named CITYSORT) to sort the city names and call a FORTRAN subroutine (named AVERAGE) to calculate the average temperature. Both of these subroutines will be provided for you in a file named SUBRS.FOR - do not write them yourself. The arguments for these subroutines will be specified later.

Your program should include at least three macro definitions and their invocations. These macros are

FINDVALUE
Uses the known location of start of a data value to determine the location of the end of the data value in an input record.

ISOLATE
UExtracts a data value (name or temperature) from an input record and puts it in the name array (if it is a name) or in a separate area where it can be converted to a 2's complement number (if it is a temperature).

SKIPSPACES
UBegins with the location of a space; skips over any number of spaces between data values in an input record; finds the location of the next non-space character (if there is one).

Here is an example of the kind of data that your program should be able to handle.
83       Accra     Miami                  Albuquerque
103,80,   Rome,                       67 Quito
   64 
          Madrid,54,-4 Montrea
 Lima    London,Dakar     87     70     62