based
on your paygrade and years of sea duty. You would need a two-dimensionalarray
(matrix) to store the data. Figure 5-1 shows the table ofvalues
needed to determine sea pay.

Examine the following program and see how the matrix is

constructed.
The program contains nested loops (lines 20-60) whichare
used to read the values into the matrix. The outer loop setsup
the row portion, G, which represents paygrade. The innerloop
sets up the column portion, S, which represents the yearsof
sea duty.

Figure 5-1.—Sea-pay table.

Example:

As seen in the output from this program, an E-8 with 7 years sea duty

would
receive $285.00 sea pay. Try the program and see what your sea paywould
be.

The paygrade (4-9) is entered (line 100). Before it can be used as a
subscript

to determine row number, we
subtract 3 (line 110). This makes it correspondto
row number 1-6. Next, years of sea duty (1-12) are entered to be used asthe
subscript for column number. Then the PRINT statement (line 140) printsthe
corresponding value of the coordinates G and S from the matrix named P.