MATLAB: Hello, how can I fix this function? I’m new to MATLAB

new

I'm trying to create a code that allows me to input test grades and with that grade display a letter grade
function[MYCOURSEGRADE]=Problem(k)
y=input('Grade Value for Exam1:');
x=0.35*(y);
p=input('Grade Value for Exam2:');
s=0.4*(p);
R=input('Grade for Recitation Work:');
d=0.25*(R);
k=x+s+d;
disp('Total Grade Value is:');
disp(k)
if k>=90 && k<=100
MYCOURSEGRADE='A';
elseif k>=86 && k<=89
MYCOURSEGRADE='B+';
elseif k>=80 && k<=85
MYCOURSEGRADE='B';
elseif k>=75 && k<=79
MYCOURSEGRADE='C+';
elseif k>=65 && k<=74
MYCOURSEGRADE='C';
elseif k>=55 && k<=64
MYCOURSEGRADE='D';
elseif k<=54
MYCOURSEGRADE='F';
disp(MYCOURSEGRADE)
end
end

Best Answer

Remove the second
function[MYCOURSEGRADE]=Problem(k)
Move the line
disp(MYCOURSEGRADE)
one line down, to after the 'end' you have there. Or remove that line, since you will be returning the grade from the function.
Related Question