function dish ( trial_num )

%*****************************************************************************80
%
%% dish() counts how often a single dishwasher breaks 4 out of 5 dishes.
%
%  Discussion:
%
%    Five dishwashers are at work.  During the week, 5 dishes are broken.
%    What are the chances that at least 4 out of 5 dishes are broken
%    by the same clumsy dishwasher?
%
%  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, 'dish():\n' );
  fprintf ( 1, '  Five dishwashers work together.  Five dishes are broken.\n' );
  fprintf ( 1, '  What are the chances that at least four of the dishes\n' );
  fprintf ( 1, '  are broken by the same particular dishwasher?\n' );

  clumsy = 0;

  for k = 1 : trial_num

    broken_dishes = 0;
    for j = 1 : 5
      r = rand ( );
      if ( r < 0.2 )
        broken_dishes = broken_dishes + 1;
      end
    end

    if ( 3 < broken_dishes )
      clumsy = clumsy + 1;
    end

  end

  clumsy = clumsy / trial_num;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Probability dishwasher #1 breaks at least 4 out of 5 dishes = %g\n', clumsy );
  fprintf ( 1, '  Theoretical probability is %g\n', 21 / 3125 );

  return
end
