function knapsack_dynamic_test01 ( p, w, c )

%*****************************************************************************80
%
%% knapsack_dynamic_test01() tests knapsack_dynamic().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    29 October 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer p(n): the "profit" or value of each object.
%
%    integer w(n): the "weight" or cost of each object.
%
%    integer C: the maximum weight capacity for the knapsack.
%
  n = length ( p );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Number of objects is %d\n', n );
  fprintf ( 1, '  Knapsack capacity is %d\n', c );
  fprintf ( 1, '  Object weights:\n' );
  disp ( w );
  fprintf ( 1, '  Object values: \n' );
  disp ( p );

  object = knapsack_dynamic ( p, w, c );

  fprintf ( 1, '\n' );
  fprintf ( 1, '   #  Index  Weight  Value\n' );
  fprintf ( 1, '\n' );
  w_total = 0;
  p_total = 0;
  object_num = length ( object );
  for i = 1 : object_num
    j = object(i);
    fprintf ( 1, '  %2d     %2d   %5d  %5d\n', i, object(i), w(j), p(j) );
    w_total = w_total + w(j);
    p_total = p_total + p(j);
  end

  fprintf ( 1, '         --   -----  -----\n' );
  fprintf ( 1, '  Total: %2d   %5d  %5d\n', object_num, w_total, p_total );

  return
end

