MATLAB Grader -- assessing functions
显示 更早的评论
Reference Solution:
function results = drinking_age(x)
if x < 0
results = 'Invalid age'
end
if x >= 21
results = 'You are of drinking age'
else
results = 'You are not of drinking age'
end
end
Assessment:
% Run learner solution.
x = 1;
results = drinking_age(x);
% Run reference solution.
yReference = reference.drinking_age(x);
% Compare.
assessVariableEqual('results', yReference);
The assessment claims all is good : x=25 drinking_age(x)
When I change the >= to ==, the assessment says all is good
function results = drinking_age(x)
if x < 0
results = 'Invalid age'
end
if x == 21
results = 'You are of drinking age'
else
results = 'You are not of drinking age'
end
end
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Use Content in an LMS Course 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!