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
shepuryov [24]
2 years ago
13

Rewrite this if/else if code segment into a switch statement int num = 0; int a = 10, b = 20, c = 20, d = 30, x = 40; if (num &g

t; 101 && num <= 105) { a += 1; } else if (num == 208) { b += 1; x = 8; } else if (num > 208 && num < 210) { c = c * 3; } else { d += 1004; }
Computers and Technology
1 answer:
Tanya [424]2 years ago
3 0

Answer:

public class SwitchCase {

   public static void main(String[] args) {

       int num = 0;

       int a = 10, b = 20, c = 20, d = 30, x = 40;

       switch (num){

           case 102: a += 1;

           case 103: a += 1;

           case 104: a += 1;

           case 105: a += 1;

           break;

           case 208: b += 1; x = 8;

           break;

           case 209: c = c * 3;

           case 210: c = c * 3;

           break;

           default: d += 1004;

       }

   }

}

Explanation:

  • Given above is the equivalent code using Switch case in Java
  • The switch case test multiple levels of conditions and can easily replace the uses of several if....elseif.....else statements.
  • When using a switch, each condition is treated as a separate case followed by a full colon and the the statement to execute if the case is true.
  • The default statement handles the final else when all the other coditions are false
You might be interested in
Bulleted and Numbered List button appear in the ………….. Toolbar.​
stich3 [128]

Answer:

The answer to this question is given below in the explanation section

Explanation:

Bulleted and Numbered List button appear in the <u>Paragraph </u>Toolbar.​

On word processing software, these options display in paragraph toolbar in the Home ribbon.

for example, in MS Word, you can find them in the Home tab under paragraph groups of command.

however, it is noted that these options are appear in some other software under the formating toolbar.

8 0
3 years ago
The entities on which data are collected are _____.
sasho [114]

Answer:

<h2>ELEMENT</h2>

Explanation:

<h3>hope it helps you!!!</h3>
8 0
2 years ago
What is a variable?
aleksandr82 [10.1K]
Answer. D: a value that looks loads when the program runs.


Explanation:

In programming, a variable is a value that can change, depending on conditions or on information passed to the program. Typically, a program consists of instruction s that tell the computer what to do and data that the program uses when it is running.
5 0
3 years ago
If you accidentally put an envelope in the Express Mail box will it still get to its destination?
Gnoma [55]
It depends because if you put a stamp on the envelope. But I think that it will still get to the destination. I think that it will either get sent to the destination or not. But you never know what is going to happen.
8 0
2 years ago
Horizontal lines should be avoided in photographs t/f
Temka [501]
I belived its true is the answer
3 0
2 years ago
Other questions:
  • Which view In a presentation program displays you’re slides in full screen modes ?
    8·2 answers
  • A company that hires only American Indians is practicing
    5·2 answers
  • Which is the last step in conducting a URL search?
    14·1 answer
  • How can you logout your account and do not want to have this anymore
    12·2 answers
  • Describe how to manipulate artwork in a presentation.
    13·1 answer
  • Elizabeth types in the following search terms: "Adoption AND cats AND NOT Persians." what results will her search provide?
    12·2 answers
  • Pls help is very urgent and I will mark u as brainliest plsssss​
    11·2 answers
  • Which are factors that go into a project plan?
    8·1 answer
  • What permission do users have by default regarding printer access and the ability to manage documents?
    14·1 answer
  • HELP PLX ITS PYTHON BTW!!!
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!