% ifElseExample3.m    P. Conrad for CISC106, 09/25/2006
% illustrate how to use an if/elseif/else

% Ask user to input a grade, 
% Then, print whether the grade is a passing or failing grade.
% Treat "Perfect Score" and "Zero" as special cases.

% The following shows how to test for multiple conditions
% using && as the logical operator for "and" (see notes* at end of file)

grade = input('Enter a grade: ');

if (grade == 100)
     display('Perfect Score');
elseif (grade >= 60)
     display('Passed');
elseif ((grade <  60) && (grade ~= 0))
     display('Failed');
else
     display('Zero');
end


% *Notes:

% (1)  The test ((grade <  60) && (grade ~= 0)) is actually redundant,
%      because we have already ruled out the possibility that grade was
%      greater than or equal to 60 in the previous condition.
%   
%      So (grade < 60) MUST be true for this condition to even be reached.
%
% (2)  The double &, i.e. && is actually the "short-circuit version" of and.
%      See your textbook for an explanation

