Introduction
A program is required to convert the unsorted Client-Names file of free-format, variable length, records into a sorted file of fixed length records. The sorted file must be sorted into ascending Client-Name within ascending County-Name. In addition to converting and sorting the file, the program must ensure that the county name is valid and must convert it to a county number.
File Descriptions
The Client-Names File (input)
The records of the Client-Names file are unsorted, free-format, variable length records where the fields are separated by commas. While the fields do not occupy specific character positions, they are in a specific order. The Client-Name is first, the Client-Address is next and the Client-Number is last. The fields also have a maximum size. The Client-Name is a maximum of 35 characters, the Address is a maximum of 60 characters long and the Client-Number is always 4 digits long.
The constituent parts of the fields are separated by one or more spaces. The fields may be upper case or lower case or a mixture of these. In the Address field the County Name will always be the last part of the address.
Some example records are;
Michael Terence Ryan,34 Winchester Drive Dublin 3 Co. Dublin,0123 MARY TYLER MOORE,THIS IS AN INVALID ADDRESS,1432 Fred James Hoyle,17 Starry Lane Cork Co. Cork,0012
The Sorted-Clients File (output)
The Sorted-Clients file is produced from the unsorted Client-Names file. The records of the file must be fixed length records held in ascending Client-Name within ascending County-Num. Each record has the following description.
|
Field |
Type |
Length |
Value |
| Client-Name | X |
30 |
-- |
| Client-Address | X |
45 |
-- |
| County-Num | 9 |
2 |
1-32 |
| Client-Num | 9 |
4 |
0001-9999 |
This file only contains records with valid county names. Records with invalid county names must be written to an error file.
The Client-Name in the sorted file must have the surname first so that the sorting will be done correctly.
Some sample records are;
Hoyle Fred James 17 Starry Lane Cork Co. CORK 060012
Ryan Michael Terence 34 Winchester Drive Dubline 7 Co. Dublin 090123
The Error File
Any records that are found to contain invalid county names are sent to an Error File. This file has the same format as the input file
An example error record is;
Mary Tyler Moore,This is an invalid address,1435
Appendix
The names, and corresponding county numbers, of the 32 counties of Ireland are given in the table below.
|
County Num
|
County Name
|
1 |
Antrim |
2 |
Armagh |
3 |
Carlow |
4 |
Cavan |
5 |
Clare |
6 |
Cork |
7 |
Derry |
8 |
Donegal |
9 |
Down |
10 |
Dublin |
11 |
Fermanagh |
12 |
Galway |
13 |
Kerry |
14 |
Kildare |
15 |
Kilkenny |
16 |
Laois |
17 |
Leitrim |
18 |
Limerick |
19 |
Longford |
20 |
Louth |
21 |
Mayo |
22 |
Meath |
23 |
Monaghan |
24 |
Offaly |
25 |
Roscommon |
26 |
Sligo |
27 |
Tipperary |
28 |
Tyrone |
29 |
Westmeath |
30 |
Waterford |
31 |
Wexford |
32 |
Wicklow |