MATLAB Grader -- assessing functions
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Use Content in an LMS Course finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!