with ada.text_io; use ada.text_io; 
with ada.integer_text_io; use ada.integer_text_io; 
with ada.float_text_io; use ada.float_text_io; 
 
procedure emp5  is 

    -- A type for a single employee
    type Employee is record
        name: String(1..20);
        id: String(1..6);
        salary: Float;
    end record;

    -- A type for storing employees
    type EmpArray is array(1 .. 100) of Employee;

    -- A type for storing an array of employees and a count
    -- of how many valid employees are currently in the array
    type EmployeeList is record
        emps: EmpArray;
        count: Natural := 0;   -- Initialize
    end record;

    -- Get the employees and count them
    procedure getEmps(el: out EmployeeList) is

        -- Stores an employee as it's populated, then stored in the array
        e: Employee;

    begin
        skip_line;                -- Skip the header line
        while not end_of_file loop
            -- Populate an employee record
            get(e.name);
            get(e.id);
            get(e.salary);

            -- Count and store the employee that was read
            el.count := el.count + 1;
            el.emps(el.count) := e;
        end loop;
    end getEmps;

    -- Output in reverse the employees with high salaries
    procedure putEmps(elist: EmployeeList) is

        -- A local for storing a copy of an employee
        e: Employee;
    begin
        for i in reverse 1 .. elist.count loop

            -- Pull out a copy of an employee, for convenience
            e := elist.emps(i);            

            if e.salary > 100_000.00 then

                -- For an example, let's access the name using the long way
                put(elist.emps(i).name);  
                put(e.id);
                put(e.salary, fore=> 7, aft=> 2, exp=>0);
                new_line;
            end if;

        end loop;
    end putEmps;

    -- Allocate an employee list
    emplist: EmployeeList;

begin
    getEmps(emplist);
    putEmps(emplist);
end emp5;