MATLAB Grader -- assessing functions
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Use Content in an LMS Course in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!