1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
galina1969 [7]
3 years ago
11

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. The following script first generates a random force value. Then, it prints a message regarding what type of wind that force represents, using a switch statement. If random number generated is 0, then print "there is no wind", if 1 to 6 then print "this is a breeze", if 7 to 9 "this is a gale", if 10 to 11 print "this is a storm", if 12 print "this is a hurricane!". (Hint: use range or multiple values in case statements like case {1,2,3,4,5,6})
Required:
Re-write this switch statement as one nested if-else statement that accomplishes exactly the same thing. You may 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
Computers and Technology
1 answer:
joja [24]3 years ago
4 0

Answer:

The equivalent if statements is:

ranforce = randi([0, 12]);

if (ranforce == 0)

     disp('There is no wind')

else  if(ranforce>0 && ranforce <7)

     disp('There is a breeze')

else  if(ranforce>6 && ranforce <10)

     disp('This is a gale')

else  if(ranforce>9 && ranforce <12)

     disp('It is a storm')

else  if(ranforce==12)

     disp('Hello, Hurricane!')

end

Explanation:

<em>The solution is straight forward.</em>

<em>All you need to do is to replace the case statements with corresponding if or else if statements as shown in the answer section</em>

You might be interested in
What computing platform was designed to help a beginner create interactive objects that receive input from sensors and use that
Arturiano [62]
The answer is <span>Arduino.  It is the </span>computing platform which was designed to help a beginner create interactive objects that receive input from sensors and use that input to control lights, motors, and other physical objects.  It<span> can be used to develop stand-alone interactive objects or can be connected to software on your computer.</span>
3 0
4 years ago
Validating the users claimed identity is called which of the following?A. AuthenticationB. IdentificationC. VerificationD. Valid
soldier1979 [14.2K]

Answer:Authentication

Explanation:

3 0
3 years ago
Which of the following office online apps is most effective for creating multi media presentation
Brrunno [24]
Google slides is the best out there
3 0
3 years ago
Read 2 more answers
What can you find the under the privacy policy section of a shopping website?
masya89 [10]

The privacy policy will tell you what the site will do with your information.

7 0
3 years ago
What are the TV resolutions
Leokris [45]
Numbers like 1080p and 4K refer to a TV's<span> screen </span>resolution and<span> the more pixels a screen has the more picture detail it can show.</span>
6 0
3 years ago
Other questions:
  • A(n) _______ is a collection of related data organized in a way that facilitates data searches.
    6·1 answer
  • Instructions:Select the correct answer.
    8·1 answer
  • What Windows Server 2016 feature leverages the storage contained on a network of servers and adds a new level of fault tolerance
    14·1 answer
  • How has information technology made piracy possible?
    6·1 answer
  • I really love my voice when not recorded. Now when I record my voice, I feel like its high pitched and horrible. Do I really sou
    11·1 answer
  • To draw a clustered cylinder chart, first select the data to be charted and then click the column button (insert tab | charts gr
    13·1 answer
  • How do productivity programs most benefit the way we work and live?
    12·2 answers
  • Why media is far from government​
    6·2 answers
  • TRUE OR FALSE
    14·1 answer
  • What microphone is this
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!