Computer Science, asked by Anonymous, 7 months ago

5) Rewrite the following program segment using switch case.
char code;
if(code==’B’ || code==’b’)
System.out.println(“Bank Manager”);
if(code==’C’ || code==’c’)
System.out.println(“Chartered Accountant”);
if(code==’E’ || code==’e’)
System.out.println(“Engineer”);
if(code==’M’ || code==’m’)
System.out.println(“Minister”);

Answers

Answered by SomeOneThere
2

Answer:

Hey Mate! Here is your answer, you can use multiple statements in switch - case.

Explanation:

char code;

switch (code)

{

case 'B', 'b' : System.out.println("Bank Manager");

break;

case 'C', 'c' : System.out.println("Chartered Accountant");

break;

case 'E', 'e' : System.out.println("Engineer");

break;

case 'M', 'm' : System.out.println("Minister");

break;

}

Similar questions