conditionals and character arrays to assign grade based on score
7 次查看(过去 30 天)
显示 更早的评论
function grade = assignGrade(score)
%Enter the commands for your function here.
if (score >= 90) && (score <= 100)
grade = 'A'
end
This is my code to call my function:
score = 75;
grade = assignGrade(score)
assignGrade(91)=grade
none of this works but I have included it to show you what I have tried
0 个评论
采纳的回答
Walter Roberson
2020-11-15
score = 75;
grade = assignGrade(score);
fprintf('The grade for score %d was %s\n', score, grade);
function grade = assignGrade(score)
%Enter the commands for your function here.
if (score >= 90) && (score <= 100)
grade = 'A';
else
grade = 'undefined';
end
end
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!