% month_length.m
% Compute DAYS, the number of days in a month.
%
%  Months are represented by 1 for January, 2 for February, and so on.
%
%  This script does not worry about leap years.
%
m = input ( '  Enter the month to check (1-12): ' );

if ( m == 9 || m == 4 || m == 6 || m == 11 )
  days = 30;
elseif ( m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12 )
  days = 31;
elseif ( m == 2 )
  days = 28;
else
  error ( '  You entered an illegal month number.' );
end
%
%  Report.
%
fprintf ( '  The number of days in month %d is %d\n', m, days );

