{ Sample Free Pascal program — samplefiles.com }
program Sample;

{$mode objfpc}{$H+}

type
  TCustomer = record
    Id: Integer;
    Name: string;
    Balance: Double;
  end;

function MakeCustomer(Id: Integer; const Name: string; Balance: Double): TCustomer;
begin
  Result.Id := Id;
  Result.Name := Name;
  Result.Balance := Balance;
end;

function IsVip(const C: TCustomer): Boolean;
begin
  Result := C.Balance >= 10000;
end;

function PadRight(const S: string; Width: Integer): string;
begin
  Result := S + StringOfChar(' ', Width - Length(S));
end;

var
  Customers: array[1..3] of TCustomer;
  I: Integer;
  Total: Double;
  Tag: string;
begin
  Customers[1] := MakeCustomer(1, 'Ada', 12500.0);
  Customers[2] := MakeCustomer(2, 'Grace', 830.5);
  Customers[3] := MakeCustomer(3, 'Linus', 10000.0);
  Total := 0;
  for I := Low(Customers) to High(Customers) do
  begin
    if IsVip(Customers[I]) then Tag := 'VIP' else Tag := '';
    WriteLn(PadRight(Customers[I].Name, 6), ' ', Customers[I].Balance:10:2, ' ', Tag);
    Total := Total + Customers[I].Balance;
  end;
  WriteLn('Total: ', Total:0:2);
end.
