% hw017.m
% John Burkardt
% What month does the N-th day occur in?
%
n = input ( '  Enter a day number between 1 and 365:' );

month = { 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' };
days =  [  31,    28,    31,    30,    31,    30,    31,    31,    30,    31,    30,    31 ];

d = 0;
for m = 1 : 12
  d = d + days(m);
  if ( n <= d )
    fprintf ( '  Day %d occurs in %s\n', n, month{m} );
    break;
  end
end
