Q:

Write the script from the previous exercise using a switch statement instead

0

 Write the script from the previous exercise using a switch statement instead. 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

total answers (1)

Similar questions


need a help?


find thousands of online teachers now