From: Rune Allnor on
On 12 Mar, 07:13, "Sarah " <proper...(a)yahoo.com> wrote:
> The assignment is to make a script that will let the user input a month such as 'January' or 'Jan' and have the output be something like 'The month is 1.' (For Feb, 'The month is 2.' and so on...)
>
> The instructions says to use if...elseif and it also told me to use the help function to find a way to compare strings.
>
> Here is what I've gotten so far:
>
> Please let me know what I'm doing wrong and nudge me in the right direction! I'm not asking anyone to do my homework for me, just a bit of help! Thanks.
>
> %%%%%%%%%%%%%%%%%%%%%%

These two lines are the base of the problem:

> input('Enter Month Name: ');

Whatever the user types is not stored anywhere, so you
can't use it in the remains of the program.

> if January =='Month';

This line tests a variable named Januar to see if it
contains the text 'Month'. You probably got it the
wrong way around.

Try this instead:

% Note that the yuser input is stored
% in the variable Month
Month = input('Enter Month Name: ');

% The contents of the variable Month (no
% apostrophes) is compared to the string
% 'January' (with apostrophes).
if strcmpi(Month,'January')
disp ('The month is 1');
end

Rune