Internal Sorts

This is a program that uses internal sorts. The program should have three distinct modules:

You will need to include COPY and CALL statements in your program. This means that you should set up the file description and a procedure division routine as source code on your disk and COPY them into your program. The sorts should be done in separate modules and executed using the CALL statement.

You will need to set up to tables in your program to accumulate data - one for last years sales and one for this years sales. The tables should contain department number and accumulator slots to accumulate last years sales by department and this years sales by dept. The accumulator slots should start out as zero. You need to set up a table of department names (you make up the names - I’m out of originality) to correspond to the department numbers.

On the printline you need to print the lines in order by last years sales. The lines should contain the department number, the department name, last years last years sales and this years sales along with a ranking of last years sales.

Module to gather the data:

Read the file named SORTDATA.DAT which is out on the Web site with the following layout:

1 - 2

Department Number

3 - 8

Last Years Sales

9 - 14

This Years Sales

 

 

You will need to read the data file and add the sales to the appropriate accumulator slots in the tables (remember, each department has a slot in both the last years and this years table and you will add to the appropriate slot).

After you read all records, you will have in the table the total sales of last year by department and the total sales for this year by department.

Sort Module:

There will be two sort modules - one for last years data and one for this years data. One of the sorts should be done using a top down sort and the other should be done using the bubble sort. Each of the sort modules should be done in a subprogram and called from you main program using the CALL statement. The table data should be passed to the subprogram, sorted there, and the sorted data passed back to the main program. In sorting the tables, you want the highest value at the top of each table and the lowest sale at the bottom of each table. Hint: Be sure that you carry the department number with the accumulated totals so that you know which total goes with which department. When both tables are sorted, you have completed the Sort Module.

Print Module:

In this module you want to print the sorted data. You are going to print a line for each department. The lines will be in order by this years sales. On each line, print the department number, the department name, this years sales, last years sales, and a message column telling where the department ranked last year. In other words, if it is fourth in the table after the sort of the last year table, it ranked fourth last year and the word FORTH should be printed in the message area.

EXAMPLE: (This does not use the sample data you are working with.)

Dept #

Dept Name

This Year Sales

Last Year Sales

Last Year Rank

 

 

 

 

 

12

TOYS

100,000

89,000

THIRD

15

SPORTS

75,000

93,000

FIRST

17

GIFTS

65,000

90,000

SECOND