changine if-elseif to a switch-case structure
Show older comments
rewrite the following code segment containing an if-elseif using a switch-case structure instead of the if-elseif. The code should not contain any ifs and should employ minimum number of disp commands. assume a is always a positive number
if a<60
disp('f)
elseif a<70
disp('d')
else
disp('good job')
my attempt was a=input(' ') switch a case a<60 disp('f') case a>= 60 & a<70 disp('d') otherwise disp('edit you') end
2 Comments
dpb
on 30 Oct 2013
Homework needs an honest attempt first -- post your work and a specific question...meanwhile, there's always
doc switch
with and example to get you kick-started...
Mike
on 30 Oct 2013
Edited: John Kelly
on 10 Nov 2017
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements 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!