-- Employee example, continued
-- Prints high salary employees in reverse
-- Stores employees in an array

with ada.text_io; use ada.text_io;
with ada.float_text_io; use ada.float_text_io;

procedure employ1  is
    type employee is record
        name: string(1 .. 20);
        id: string(1 .. 6);
        salary: float;
    end record;
    type emp_array is array(natural range <>) of employee;
    e: employee;
    the_emps: emp_array(1 .. 100);
    count: natural := 0;
begin
    skip_line;

    while not end_of_file loop
        count := count + 1;
        get(e.name);
        get(e.id);
        get(e.salary);

        the_emps(count) := e;

    end loop;
    -- for e of the_emps(1 .. count) loop -- ada 2012
    for i in reverse 1 .. count loop
        e := the_emps(i);
        if e.salary > 50_000.00 then
            put(e.name);
            put(e.id);
            put(e.salary, 9, 2, 0);
            new_line;
        end if;
    end loop;

end employ1;