i want to Write a user-defined function that calculate total marks, out of 100,The course should include homework, midterms, and final exam and i dont know why didint work

1 view (last 30 days)
function[A]=Q2pro(sum(homework),sum(midterms),FinalExam)
G1 = homework;
G2 =midterms;
G3 =FinalExam;
Gall = G1+G2+G3;
if (95 >= Gall)
disp('A+')
elseif ( 90 >= Gall)
disp('A')
elseif ( 85 >= Gall)
disp('B+')
elseif ( 80 >= Gall)
disp('B')
elseif ( 75 >= Gall)
disp('C+')
elseif ( 70 >= Gall)
disp('C')
elseif ( 65 >= Gall)
disp('D+')
elseif ( 60 >= Gall)
disp('D')
else
disp('not found')
end
end

Answers (1)

Jan
Jan on 20 May 2022
if (95 >= Gall)
Read this loud: "If 95 is greater than Gall".
No, you want the other way around:
if Gall >= 95
The header of the function should show a warning in the editor:
function[A]=Q2pro(sum(homework),sum(midterms),FinalExam)
% ^^^^ ^ ^^^^ ^
You canot use functions in the list of input arguments. I assume you mean:
function Q2pro(homework, midterms, FinalExam)
There is no output "A" also.

Categories

Find more on Debugging and Analysis in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!