Computer Science, asked by mh2388455, 6 months ago

.Rewritethefollowingfragmentusingswitch-case:

[3]

if(ch==‘E’) { east++;

System.out.println(east); }

elseif(ch==‘W’){ west++;

System.out.println(west); }

elseif(ch==‘N’){ north++;

System.out.println(north); }

else { unknown++;

System.out.println(unknown);​

Answers

Answered by Kshitij2312
0

Answer:

switch (ch) {

   case 'E':

       east++;

       System.out.println(east);

       break;

   case 'W':

       west++;

       System.out.println(west);

       break;

   case 'N':

       north++;

       System.out.println(north);

       break;

   default:

       unknown++;

       System.out.println(uknown);

}

Explanation:

I am assuming that the programming language in question is Java. If it is not, please let me know and I shall correct my answer.

Similar questions