--  File: table.adb
--
--  Description:
--
--    This file contains a program which prints a table of powers of 2
--
--  Input: <none>
--  Output: numbers 2, 2^2, 2^3, 2^4, 2^5, and 2^6 printed in
--          6 columns, with appropriate headers
--
--  Written:  Jane M. Doe

with Text_IO; use Text_IO;
procedure Table is

        BLANKS: constant STRING := "  ";   -- spacing between columns
        COLWIDTH: constant INTEGER := 8;    --  width of each column

        N,N2,N3,N4,N5,N6: INTEGER         -- stores powers of 2

        procedure PRINT_TITLES are
           --Prints headings over six columns containing powers of 2
                DASHES:   constant STRING := "------";   -- 8 dashes
                HeaderN:  constant STRING := "  N  ";   -- Column 1 header
                HeaderN2: constant STRING := "   N^2  ";  -- Column 2 header
                HeaderN3: constant STRING := "   N^3  ";  -- Column 3 header
                HeaderN4: constant STRING := "   N^4  ";  -- Column 4 header
                HeaderN5: constant STRING := "   N^5  ";  -- Column 5 header
                HeaderN6: constant STRING := "   N^6  ";  -- Column 6 header

                COUNT : INTEGER;     -- count variable, for header repetition

        begin -- PRINT_TITLES

                        -- print titles of columns
                NEW_LINE;
                PUT(BLANKS);
                PUT(HeaderN);
                PUT(BLANKS);
                PUT(HeaderN2);
                PUT(BLANKS);
                PUT(HeaderN3);
                PUT(BLANKS);
                PUT(HeaderN4);
                PUT(BLANKS);
                PUT(HeaderN5);
                PUT(BLANKS);
                PUT(HeaderN6);
                NEW_LINE;
                        --underline the six headers with dashes
                COUNT := 0;
                loop
                        exit when COUNT > 6;
                        PUT(BLANKS);
                        PUT(DASHES);
                        COUNT := COUNT + 1;
                end loop;
                NEW_LINE;

        end PRINT_TITLE;


begin  --Main Program Begins Here

           --Print out titles
        PRINT_TITLES;

        -- Compute the powers of 2
        N  := 2;
        N2 := N ** 2;            -- STEP 4
        N3 := N ** 3;            -- STEP 4
        N4 := N ** 4;            -- STEP 4
        N5 := N ** 5;            -- STEP 4
        N6 := N ** 6;            -- STEP 4

        -- Print out the powers of 2
        put(BLANKS);             -- STEP 4
        put(N,COLWIDTH);         -- STEP 4
        put(BLANKS);             -- STEP 4
        put(N2,COLWIDTH);        -- STEP 4
        put(BLANKS);             -- STEP 4
        put(N3,COLWIDTH);        -- STEP 4
        put(BLANKS);             -- STEP 4
        put(N4,COLWIDTH);        -- STEP 4
        put(BLANKS);             -- STEP 4
        put(N5,COLWIDTH);        -- STEP 4
        put(BLANKS);             -- STEP 4
        put(N6,COLWIDTH);        -- STEP 4
        NEW_LINE;                -- STEP 4

end Table;

