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]
2 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]2 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
12. What are the additional elements required of a network architecture if the enclave is to support remote access through the p
Romashka [77]

The additional elements needed of a network architecture are:

  • Policy management
  • Remote access server
  • VPN Gateway, etc.

<h3>What is network architecture example?</h3>

Network architecture is known to be the set up of a computer network. It is regarded as the backbone for the specification of the physical attributes of a network and also their functional configuration.

An examples is a printer that is linked to the network. Note that  additional elements required of a network architecture if the enclave is to support remote access through the public Internet are Policy management, etc.

Learn more about network architecture from

brainly.com/question/13986781

6 0
2 years ago
Consider the following declaration: (1, 2) double currentBalance[91]; In this declaration, identify the following: a. The array
Rom4ik [11]

Answer:

Following are the solution to the given choices:

Explanation:

Given:

double currentBalance[91];//defining a double array  

In point a:  

The name of the array is= currentBalance.  

In point b:  

91 double values could be saved in the array. It requires 8bytes to hold a double that if the array size is 91*8 = 728

In point c:  

Each element's data type is double.

In point d:  

The array index range of values is between 0 and 90 (every array index starts from 0 and ends in N-1, here N=91).  

In point e:  

To access first element use currentBalance[0], for middle currentBalance[91/2] , for last currentBalance[90]

3 0
2 years ago
You would like to search for information about storms but not tornadoes. What type of search strategy may be useful?
Norma-Jean [14]

Answer:

boolean search

Explanation:

4 0
3 years ago
Read 2 more answers
g Assignment 8: Driving costs Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon as input, a
zavuch27 [327]

Answer:

miles_gallon = float(input("Enter car's miles/gallon: "))

dollars_gallon = float(input("Enter gas dollars/gallon: "))

print("Gas cost for 20 miles is $", (20 / miles_gallon) * dollars_gallon)

print("Gas cost for 75 miles is $", (75 / miles_gallon) * dollars_gallon)

print("Gas cost for 500 miles is $", (500 / miles_gallon) * dollars_gallon)

Explanation:

*The code is in Python.

Ask the user to enter the car's miles/gallon and gas dollars/gallon

Calculate the gas cost for 20 miles, divide 20 by miles_gallon and multiply the result by dollars_gallon, then print it

Calculate the gas cost for 75 miles, divide 75 by miles_gallon and multiply the result by dollars_gallon, then print it

Calculate the gas cost for 500 miles, divide 500 by miles_gallon and multiply the result by dollars_gallon, then print it

5 0
2 years ago
Write a function named countWords that reads in a line of text into a string variable, counts and returns the number of words in
algol13

Answer:

function countWords(sentence) {

return sentence.match(/\S+/g).length;

}

const sentence = 'This sentence  has five  words ';

console.log(`"${sentence}" has ${countWords(sentence)} words` );

Explanation:

Regular expressions are a powerful way to tackle this. One obvious cornercase is that multiple spaces could occur. The regex doesn't care.

3 0
3 years ago
Other questions:
  • Read each statement below. If the statement describes a peer-to-peer network, put a P next to it. If the statement describes a s
    13·2 answers
  • Use the variables k and total to write a while loop that computes the sum of the squares of the first 50 counting numbers, and a
    10·1 answer
  • The access code for a? car's security system consists of fivefive digits. the first digit cannot be zerozero and the last digit
    13·1 answer
  • Given an array arr of type int , along withtwo int variables i and j , write some code thatswaps the values of arr[i] and arr[j]
    6·1 answer
  • PHP is based on C rather than ______.
    5·1 answer
  • I want to know why almost every single "expert answer verified" thing I come across is wrong. If it's wrong, why the h is it exp
    8·2 answers
  • In his article “is google making up stupid” Nicholas Carr uses a metaphor to suggest that
    11·2 answers
  • Im a beginner programmer. what languages should i learn and how do i get better
    13·1 answer
  • The Synonyms submenu offers a list of synonyms for a word. Is it always a good idea to use whatever synonyms are presented on th
    15·1 answer
  • Which of the following is not a component of Power BI?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!