MATLAB: Homework question, if statements

if statement

I am having trouble with this homework assignment
%1 Exercise
%Write a short code using IF construct
%that assigns a letter grade to a given numerical grade
%Do not use elseif construct, hint: nested if constructs may be useful
%95 < grade A
%86 < grade B <= 95
%76 < grade C <= 86
%66 < grade D <= 76
%0 < grade F <= 66
I have tried some n basic thing just to see if I can change the grade to a letter value, but I am having trouble. Here is an example.
grade = 97;
if(grade >= 95)
disp('A')
end

Best Answer

if(grade >= 95)
disp('A')
end
is fine as far as it goes, but it does not assign the result to anything.
if grade >= 95
gradeletter = 'A';
end
But you should be checking whether 95 exactly is 'A' or 'B'
Related Question