function value = upc_is_valid ( s )

%*****************************************************************************80
%
%% upc_is_valid() reports whether a UPC is valid.
%
%  Discussion:
%
%    UPC stands for Universal Product Code.
%
%    A full UPC is a string of 12 digits, in groups of size 1, 5, 5, and 1,
%    of the form P-LLLLL-RRRRR-C, where:
%
%      P is the one-digit product type code.
%      L is the five-digit manufacturer code.
%      R is the five_digit product code
%      C is the check digit.
%
%  Example:
%
%    0-72890-00011-8
%    0-12345-67890-5
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    10 September 2015
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    David Savir, George Laurer,
%    The Characteristics and Decodability of the Universal Product Code,
%    IBM Systems Journal,
%    Volume 14, Number 1, pages 16-34, 1975.
%
%  Input:
%
%    string S, a string containing 12 digits.
%    Dashes and other characters will be ignored.
%
%  Output:
%
%    logical VALUE: true if the string is a valid UPC.
%
  n = 12;
  dvec = s_to_digits ( s, n );

  d1 = upc_check_digit_calculate ( s );
  d2 = dvec(12);

  if ( d1 == d2 )
    value = true;
  else
    value = false;
  end

  return
end
