Computers and Technology

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

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 24.06.2019 14:30, SmartScholar4094
Two students are discussing electricity that has a frequency of 60 hz. student a says that this type of electricity is referred to as ac. student b says that in this type of electricity, the electrons flow in only one direction. which of the following statements is correct? a. only student a is correct b. only student b is correct c. both of the two students are correct d. neither of the two students is correct
Answers: 1
image
Computers and Technology, 24.06.2019 14:30, yeet74
Ahousehold consists of a married couple and their twin five-year old daughters. the couples children had no income and lived with their parents all of last year. how many exemptions can the couple claim on last years tax return or they file with the “ married filing jointly “ status? a. 4 b. 5 c. 3 d. 2
Answers: 1
image
Computers and Technology, 24.06.2019 15:30, sonyfan
What is the total number of time zones that can be configured to show by default in a calendar in outlook 2016?
Answers: 1
image
Computers and Technology, 25.06.2019 04:30, richtercatrina16
He 98 pointsss how has computers changed over the years? how can they be used now? give details and such!
Answers: 1
Do you know the correct answer?
The Beaufort Wind Scale is used to characterize the strength of winds. The scale uses integer values...

Questions in other subjects:

Konu
Biology, 08.12.2020 20:10
Konu
Mathematics, 08.12.2020 20:10