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
PLEASE HELP!!!!!
Allushta [10]

Answer:

Insert

Explanation:

Insert

7 0
3 years ago
Read 2 more answers
Looking for someone to answer these two questions
Alex777 [14]

Answer: Question 12: Answer is tables

Question 13: Answer is Command + C

Explanation:

3 0
2 years ago
Ted is asked to create a page of family photos for his family reunion Web site. He will have about 20 pictures to post, with a c
Alja [10]

Answer:

A

Explanation:

© is the symbol for copyright or Copr. for abbreviation.

7 0
3 years ago
A systemic approach to creating and ensuring channel fluidity in the flows of goods and services through shared information, com
likoan [24]

Answer:

Explanation:

The one which best describes it is Co-opetition. Co-opetition often takes place when companies which are in the same market work put aside their differences and work together in the gathering of knowledge and research of new products, but they still compete for market-share of their products and in the application of the joint knowledge created.

7 0
3 years ago
Read 2 more answers
The address entered into a web browser (firefox, safari, chrome, ie) is technically called a?
Nimfa-mama [501]

Answer: Website Bar

Explanation:

7 0
2 years ago
Other questions:
  • Which activity uses a feature of a word processor?
    7·2 answers
  • You can be sentenced to up to 180 days in jail for driving with a license that was suspended for _________ .
    15·1 answer
  • I need help <br> Match each words with its definition!!!<br> Please helpppppppp
    12·1 answer
  • When using Regedit to browse through the registry, the key that is highlighted is the ________, and its value entries are visibl
    5·1 answer
  • Components that enhance the computing experience, such as computer keyboards, speakers, and webcams, are known as
    7·1 answer
  • When determining the amount of RAM necessary for a computer you wish to purchase, what should you consider?
    7·1 answer
  • I have a question about this programming assignment. The outcome when the user puts in Taylor for guest one and Fernando for gue
    7·2 answers
  • What single awk command can be used to display all the login names and their associated numerical user IDs
    14·1 answer
  • Write an algorithm to calculate the simple interest using the formula​
    7·1 answer
  • write an algorithm to settle the following question: a bank account starts out with $10,000. interest is compounded monthly at 6
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!