MATLAB: Program not running correctly. Trying to write program to determine number of days in month.

errorMATLABmonthprogramming

% get the month and year
disp('Program to calculate number of days');
month = input('Enter the month (1-12): ');
year = input('Enter the year (####): ');
% To check the leap year
if mod(year,400) ==0
leap_year =1;
elseif mod(year,100) ==0
leap_year =0;
elseif mod(year,4) ==0
leap_year =1;
else
leap_year =0;
end
% calculate days in months
switch (1)
case 1;3;5;7;8;10;12;
days = 31;
case 4;6;9;11;
days =30;
case 2
days=28 + leap_year;
end
%print the days
fprintf ('The number of days in the month %2d is %2d days. \n',month , days) ;

Best Answer

...
switch (month)
case {1,3,5,7,8,10,12}
days = 31;
case {4,6,9,11}
days =30;
case 2
days=28 + leap_year;
end
BTW, try
type eomday
at command line... :)