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