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]
3 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]3 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
How are mathematics and computer science similar? Discuss any connections between numbers, logic, and other elements.
tester [92]

Answer:

Explanation:

Both mathematics and computer science use variables and logic in order to analyze, explain, and model real-world problems. Also mathematics is a very important part of computer science as the logic and algorithms in computer science require mathematics in order to device systems to solve these problems. For example, data structures in computer science require lots of linear algebra in order to traverse large data collections efficiently, while Artificial Intelligence would need calculus and linear algebra in order for it to be efficient.

7 0
3 years ago
Given the arra
Scrat [10]

Answer: B. hummer

Explanation:

Given the array :

Given the arra

("explorer", "testa", "hummer", "corvette", "civic", "mustang")

Array indexing usually begins from 0

That is ; the first element in the array is indexed as being in position 0

Using the given array as an example :

Index ____ element

0 ______ explorer

1 _______ tester

2 _______hummer

3 _______ corvette

4 _______ civic

5 _______ mustang

Hence, element in index 2 of the array is hummer

4 0
3 years ago
How do the following improve security <br> User Id <br> Password<br> Encryption
natima [27]
I would say password.
5 0
3 years ago
Read 2 more answers
Is number 1 correct​
Nutka1998 [239]

Answer:

Yes, number 1 is correct

Explanation:

8 0
3 years ago
Read 2 more answers
If the value of the expression,
mr Goodwill [35]

Answer:

<u>Arithmetic underflow</u>

Explanation:

Great question, it is always good to ask away and get rid of any doubts that you may be having.

Since the answer given is a negative. We can say the error that is seen here is an <u>Arithmetic underflow </u>error. This is because the answer given is a smaller absolute value which the computer cannot actually represent or save in its memory in the CPU. Therefore this is the closest representation of the arithmetic error displayed.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

8 0
3 years ago
Other questions:
  • In a(n) __________ situation, a wireless device is configured to appear to be a legitimate access point, enabling the operator t
    14·1 answer
  • Imagine your friend wants to apply
    5·1 answer
  • Write a program that takes the radius of a sphere (a floating-point number) as input and then outputs the sphere’s: Diameter (2
    7·1 answer
  • Create a class named Console, and move all the methods that retrieve and validate user input to that class. These methods can re
    7·1 answer
  • Select the correct answer.
    10·2 answers
  • Kara has been asked to create an employment application form for her company. Which of the following items can she use to make s
    10·1 answer
  • The type of medium used to hide data in steganography is referred to as __________. This may be a photo, video, sound file, or V
    12·2 answers
  • Explain the<br>4 ways<br><br>ways of arranging icons.<br><br>​
    6·1 answer
  • GMI = $4,666.67 Total Monthly Deductions $1,131.00 What is the Net Monthly Income (GMI - Total Monthly Deductions) =
    9·1 answer
  • Which layer of the OSI model provides a user interface in the form of an entry point for programs to access the network infrastr
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!