.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
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