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
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
Science,
3 months ago
Math,
3 months ago
Social Sciences,
7 months ago
English,
11 months ago
Math,
11 months ago