Three-Level Control-Break

September 29, 2017

In many data-processing shops it is standard practice to write programs that generate reports that summarize data in hierarchical groups, say a report of population by city nested within county nested within state nested with a grand total. The input data is a set of records, already sorted in the required order. The output is a printed report, often written on sprocket-fed green-bar paper (where I work, we had a high-speed line printer as late as about ten years ago). The trick, of course, is that you never know that a break has occurred until you read the record after the break, so you have to be careful to keep track of where you are in the hierarchy, and to properly initialize and complete each level of the hierarchy; the first and last records in the data set are always potential spots for error.

Your task is to write a program that produces a three-level control-break report; use any data set that interests you. When you are finished, you are welcome to read a suggested solution, or to post your own solution or discuss the exercise in the comments below.

Advertisement

Pages: 1 2

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: