Solve using MATLAB Someone has created the following code to
Solve using MATLAB
Someone has created the following code to display the frequency of subway trains in a terminal and the names of the train lines are A, B, C, D and E. Rewrite the code using a switch structure (rather than the nested if), but do not change the prompt. You may assume the user enters an upper case letter at the prompt. Line = input(\'Enter the line.\', \' s\') if Line > \'A\' & LineSolution
train =input(\"Enter name of the train\")
switch(train)
case \'A\'
fprintf(\'This train arrives every 24 minutes.\ \' );
case \'C\'
fprintf(\'This train arrives every 12 minutes.\ \' );
case \'B\'
case \'D\'
fprintf(\'This train arrives every 18 minutes.\ \' );
case \'E\'
fprintf(\'This train arrives every 30 minutes.\ \' );
otherwise
fprintf(\'This train is not in service\ \' );
end
