Computer Science, asked by kritvijain, 6 months ago

Write the below code snippet using switch statement [2]

if(code==’A’)

Sysytem.out.println(“Accountant”);

else if(code==’C’||code==’D’)

Sysytem.out.println(Grade 2);

else

System.out.println(“Consultant”);​

Answers

Answered by anindyaadhikari13
7

Question:-

Write the following code using switch-case statement.

Code:-

This is the converted code snippet,

switch(code)

{

case 'A':

System.out.println("Accountant.");

break;

case 'C':

case 'D':

System.out.println("Grade 2.");

break;

default:System.out.println("Consultant.");

}

Answered by BrainlyProgrammer
2

Answer:

Question: To convert the given code into switch statement

Code:-

switch(code)

{

case 'A': System.out.println("Accountant") ;

break;

case 'C':

case 'D': System.out.println(Grade 2) ;

break;

default:System.out.println("Consultant") ;

}

Similar questions