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!