-- Add an employee list type that contains both the array and the count
with ada.text_io; use ada.text_io;
with ada.float_text_io; use ada.float_text_io;
procedure emp3 is
type Employee is record
Name: String(1 .. 20);
ID: String(1 .. 6);
Salary: Float;
end record;
type Emp_Array is array(1 .. 10) of Employee;
-- Array plus a count of how many currently stored
type Emp_List is record
emps: Emp_Array;
num: Natural := 0;
end record;
-- Add all employees to list
procedure get_emps(emps: out Emp_List) is
e_tmp: Employee;
begin
while not end_of_file loop
emps.num := emps.num + 1;
get(e_tmp.Name);
get(e_tmp.ID);
get(e_tmp.salary);
emps.emps(emps.num) := e_tmp;
end loop;
end get_emps;
-- Print all the employees
procedure put_emps(emps: in Emp_List) is
e_tmp: Employee;
begin
for i in 1 .. emps.num loop
e_tmp := emps.emps(i);
put(e_tmp.Name);
put(e_tmp.ID);
put(e_tmp.salary, 7, 2, 0);
new_line;
end loop;
end put_emps;
the_emps: Emp_List;
begin
get_emps(the_emps);
put_emps(the_emps);
end emp3;