Write the script from the previous exercise using a switch statement instead
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:4| Question number:18.4
All Answers
total answers (1)
Ch4Ex18.m
% Prompts the user for a 'y' or 'n' answer and responds
% accordingly, using a switch statement
letter = input('Enter your answer: ', 's');
switch letter
case {'y', 'Y'}
disp('OK, continuing')
case {'n', 'N'}
disp('OK, halting')
otherwise
disp('Error')
end
need an explanation for this answer? contact us directly to get an explanation for this answer