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 is A/B Testing
Gnom [1K]
A/b testing is comparing two versions of a web page to see which one performs better
8 0
3 years ago
Read 2 more answers
DO NOT JOIN ANY Z O O M MEETINGS FROM THIS PERSON! IS A TRAP Please help me get them banned!!!!!
s2008m [1.1K]

Answer:

how do i help?

Explanation:

7 0
3 years ago
Read 2 more answers
Every page on a website must be updated recently to consider the website updated/maintained
guajiro [1.7K]
Unmaintained. hope that helped
6 0
3 years ago
Read 2 more answers
How does a light bulb work
koban [17]
A light bulb is usually powered by a wire producing electricity. The energy can also come from wind turbines or solar panels.

Hope this helps
7 0
3 years ago
Read 2 more answers
1. From where you can access save command?
Alja [10]

Answer:

1 no. ans

none of above

this ans is not 100% correct but also it help may help you

4 0
3 years ago
Other questions:
  • Write a function that iteratively appends random 1's and 0's to an array to form a binary number. The function returns the binar
    13·1 answer
  • Explain Cascading Style Sheets and what they do. Describe their primary function, two effects that this function has on programm
    11·1 answer
  • What does this say:<br> √ans
    6·2 answers
  • What type of file can most software applications read?
    5·2 answers
  • Please help me answer this question
    14·1 answer
  • What inspired john logie baird to create the television?
    11·1 answer
  • Which of the following combines something you know, such as a password, with something you are (a biometric device such as a fin
    13·1 answer
  • With respect to computer networks, organizations often install a dedicated telephone system called a ________ to route external
    8·1 answer
  • What is essential to delivering a successful presentation?
    5·2 answers
  • 1.) Florida has ____________ roads that are designated as part of the National Highway System.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!