Computer Science, asked by MasterQuestioner, 1 year ago

Rewrite the following set of if-else statement in terms of switch case statement for the
following code fragment:
int code;
code=sc.nextlnt();
if (code==1)
System.out.print(" Accountant");
else
if (code==5 || code==6)
System.out.print("Grade IV");
else
if (code==3)
System.out.print("Financial Advisor");

Answers

Answered by duragpalsingh
18

Hey there!

The program using switch case statement would be:

int code;

code=sc.nextInt();

switch(code)

{

case 1:

System.out.print("Accountant");

break;

case 5:

case 6:

System.out.print("Grade IV");

break;

case 3:

System.out.print("Financial Advisor");

}

Hope It Helps You!

Similar questions