function malt ( trial_num )

%*****************************************************************************80
%
%% malt() estimates the chances that Lil and Bill will meet at the malt shop.
%
%  Discussion:
%
%    Lil and Bill agree to meet in the malt shop between 3:30 and 4:00.
%    Each arrives at a random time.
%    Lil will wait 5 minutes, then leave.
%    Bill will wait 7 minutes, then leave.
%    What is the probability of a meeting?
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    23 January 2018
%
%  Author:
%
%    Paul Nahin
%
%  Reference:
%
%    Paul Nahin,
%    Digital Dice: Computational Solutions to Practical Probability Problems,
%    Princeton, 2008,
%    ISBN: 978-0-691-15821-1.
%
%  Input:
%
%    integer trial_num: the number of trials.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'malt():\n' );
  fprintf ( 1, '  Lil and Bill agree to meet in the malt shop between 3:30 and 4:00.\n' );
  fprintf ( 1, '  Each arrives at a random time.\n' );
  fprintf ( 1, '  Lil will wait 5 minutes, then leave.\n' );
  fprintf ( 1, '  Bill will wait 7 minutes, then leave.\n' );
  fprintf ( 1, '  What is the probability of a meeting?\n' );

  meetings = 0;

  for loop = 1 : trial_num

    L = 30 * rand ( );
    B = 30 * rand ( );

    if ( B < L && L < B + 7 )
      meetings = meetings + 1;
    elseif ( L < B && L > B - 5 )
      meetings = meetings + 1;
    end

  end

  meetings = meetings / trial_num;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Estimated meeting probability = %g\n', meetings );
  fprintf ( 1, '  Theoretical probability is %g\n', 1 - 1154/1800 );

  return
end
