Replace the following set of if-else statements with switch-case statements:-
void work(char code)
{
if(code==’A’)
System.out.println(“Accountant”);
else if(code==’C’ || code==’G’)
System.out.println(“Grade IV”);
else if(code==’F’)
System.out.println(“Financial Advisor”);
[4]
}
Answers
Answered by
6
Program is given below.
Explanation:
void work(char code)
{
switch(char code)
case A: System.out.println(“Accountant”);
break;
case C: System.out.println(“Grade IV”);
break;
case G: System.out.println(“Grade IV”);
break;
case F: System.out.println(“Financial Advisor”);
break;
default: System.out.println(“Enter a valid character”);
}
Similar questions
Political Science,
3 months ago
Math,
3 months ago
Math,
8 months ago
Math,
8 months ago
Math,
1 year ago