MATLAB: Write a script that will prompt the user for the month of interest.

caseexception statementfunctioninputpromptscriptswitch

Best Answer

Don't have the function keyword since it's supposed to be a script. You need to do something like
theMonth = input('Enter a month: ','s');
switch lower(theMonth)
case {'dec', 'jan', 'feb'}
season = 'Winter';
case {'mar', 'apr', 'may'}
season = 'Spring';
case {'jun', 'jul', 'aug'}
season = 'Summer';
case {'Sep', 'oct', 'nov'}
season = 'Autumn';
otherwise
season = 'Unknown';
end
fprintf('%s is a month in %s.\n', theMonth, season)