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
In-s [12.5K]
3 years ago
6

Rewrite the following nested if-else statement as a switch statement that accomplishes exactly the same thing. Assume that num i

s an integer variable that has been initialized, and that there are functions f1, f2, f3, and f4. Do not use any if or if-else statements in the actions in the switch statement, only calls to the four functions.
Engineering
1 answer:
seropon [69]3 years ago
8 0

Answer:

Answer explained below

Explanation:

The following is the nested if-else statement:

% if-based statement

if num < -2 ||  num > 4

          f1(num)

else

     if num <=2

          if num >= 0

              f2(num)

          else

              f3(num)

          end

     else

          f4(num)

     end

end

<u>NOTE:</u> the num is an integer variable that has been initialized and that there are functions f1, f2, f3 and f4.

   

The nested if-else statement can be replaced by switch statement as shown below:

switch num

    case(0, 1, 2)

         f2(num)

    case(-2, -1)

         f3(num)

    case(3, 4)

         f4(num)

    otherwise

         f1(num)

In this case, the switch based code is easier to write and understand because the cases are single valued or a few discrete values (not ranges of values)

You might be interested in
Entrence is one of the animation category​
krek1111 [17]

Answer:Videos

Video result for entrance is one of the animation category​

PREVIEW

3:31

Choosing a style of entrance animation effects | Microsoft ...

Jun 7, 2015

Video result for entrance is one of the animation category​

PREVIEW

4:23

Video: Animate text - PowerPoint

Microsoft Support

View all

Explanation:

3 0
3 years ago
an object of mass 2kg is released from a top of inclined plane 30° and height 6m. The coefficient of kinetic friction of the sur
mel-nik [20]

Explanation:

1) Work done = force x distance x cos(θ)

= 0.15 x 6 x cos(30)

= 0.779

2) Ek = ½mv²

v = acceleration due to gravity so 9.81

Ek = ½(2)(9.81)²

Ek = 96.2361

3) v = (√(2em)) / m

= (√(2(96.2361)(2)) / 2

= 9.81 so especially with no time given, I can only assume the acceleration due to gravity but take it with a pinch of salt.

5 0
2 years ago
The strength and stiffness of a properly constructed composite buildup depends primarily on?
Flauer [41]

Answer:orientation of piles

Explanation:

The stiffness and strength of a properly constructed composite buildup depend upon the orientation of piles to the load direction.

Structural composite materials are designed and manufactured to withstand certain specific stress loads. The ability to withstand these stress loads depends, to a large extent, on how the fibers are arranged. The fiber orientation of the parts must be the same as that of the original form.          

4 0
3 years ago
The net potential energy EN between two adjacent ions, is sometimes represented by the expression
Anastaziya [24]

Answer:

as answered in the attached file.

Explanation:

The detailed steps, derivation and appropriate differentiation is as shown in the attachment

3 0
3 years ago
Hi,I want to know something.
Paha777 [63]

Answer:

So it looks to me that, Yes, you can find 10-50 leds on Amazon. You just have to be specific and search 10-50 led Christmas lights for windows, or something along those lines. Also try filtering the results, and reading the descriptions and reviews. This should help you out, and if it doesn't then I'm sorry.

Good luck friend :)

8 0
3 years ago
Other questions:
  • The volume at a section of a 2-lane highway is 1800 vph in each direction and the density is approximately 30 bpm. A slow moving
    10·1 answer
  • Create a program named IntegerFacts whose Main() method declares an array of 10 integers.Call a method named FillArray to intera
    12·1 answer
  • Fred wants to help his customer understand his vision for constructing the office interior. Which visual representation will bes
    8·1 answer
  • A thick oak wall initially at 25°C is suddenly exposed to gases for which T =800°C and h =20 W/m2.K. Answer the following questi
    5·1 answer
  • Please write the following code in Python 3. Also please show all output(s) and share your code.
    10·1 answer
  • What is JIT and why would you advocate it to reduce inventory?
    8·1 answer
  • Determine the maximum weight of the flowerpot that can besupported without exceeding a cable tension of 50 lb in eithercable AB
    15·1 answer
  • what is the expected life 1 inch diameter bar machined from AISI 1020 CD Steel is subjected to alternating bending stress betwee
    9·1 answer
  • What does it mean if a manufacturing company "retools"?
    7·2 answers
  • Accidents occur as a result of ____ and ____.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!