by BillyBoyo » Mon Apr 11, 2011 8:07 pm
Hi Pumpkin,
Firstly, data definitions. Nothing directly to do with your problem, but here I go.
If you are going to do a calculation with something, make it numeric, ideally comp-3 and an odd-number of digits. If you have a number which you are not going to do a calculation with, so it is something that just happens to be numbers instead of letters, make it PIC X. So item number, PIC XXX. Item price, COMP-3 PIC S9(5). If you use a subscript/loop counter, make it COMP PIC S9(4).
You have a price with no decimal places, but I'm assuming that is for your local currency.
Now your problem. If you are able to sort your data, then it is easy (sort descending, first ten entries/records are the ones you want).
If you want to do the sort yourself, I'm sure you'll find some outlines for things like Bubblesort, Quicksort and whatever is up-to-date.
As you are going to have two tables it would be possible to do an exchange-as-you-search sort of thing. Let us know if your next step requires more assistance, but think about it yourself first as much as possible, and let us know how you arrived at getting stuck (or at your solution).
Or, by the time I finished writing this, just review Robert's solution. I'd just ditch the sorting bit and do it as you go along, but this is a fine solution if you want practice putting together your own sort (which you will find future uses for, so it is not time lost).