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!