To write:
The script for the following switch statement give below first generates a random force value. Then, prints a message regarding what type of wind that force represents, using a switch statement. And rewrite this switch statement as one nested if-else statement that accomplishes exactly the same thing. Use else and/or elseif clauses.
ranforce = randi([0, 12]);
switch ranforce
case 0
disp('There is no wind')
case {1, 2, 3, 4, 5, 6}
disp('There is a breeze')
case {7, 8, 9}
disp('This is a gale')
case {10, 11}
disp('It is a storm')
case 12
disp('Hello, Hurricane!')
end
In which, the Beaufort Wind Scale is used to characterize the strength of winds. The scale uses integer values and goes from a force of 0, which is no wind, up to 12, which is a hurricane.
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
Matlab, Fourth Edition: A Practical Introduction to Programming and Problem Solving
- Algebra: Structure And Method, Book 1AlgebraISBN:9780395977224Author:Richard G. Brown, Mary P. Dolciani, Robert H. Sorgenfrey, William L. ColePublisher:McDougal LittellAlgebra & Trigonometry with Analytic GeometryAlgebraISBN:9781133382119Author:SwokowskiPublisher:CengageElementary Geometry For College Students, 7eGeometryISBN:9781337614085Author:Alexander, Daniel C.; Koeberlein, Geralyn M.Publisher:Cengage,
- Holt Mcdougal Larson Pre-algebra: Student Edition...AlgebraISBN:9780547587776Author:HOLT MCDOUGALPublisher:HOLT MCDOUGALElementary AlgebraAlgebraISBN:9780998625713Author:Lynn Marecek, MaryAnne Anthony-SmithPublisher:OpenStax - Rice UniversityMathematics For Machine TechnologyAdvanced MathISBN:9781337798310Author:Peterson, John.Publisher:Cengage Learning,