•Use Java to rewrite the following code segment using a switch statement. Do not optimize the code, just do a direct translation to switch statement:
if ((k == 1) || (k == 2)) j = 2*k -1
if ((k==3) || (k==5)) j=3*k+1
if (k==4) j=4*k-1
if ((k==6) || (k==7) || (k==8)) j=k-2
if ((k == 1) || (k == 2)) j = 2*k -1
switch(k){
case 1:
case 2:
j = 2*k -1;
break;
case 3:
case 5:
j=3*k+1;
break;
case 4:
j=4*k-1;
break;
case 6:
case 7:
case 8:
j=k-2;
}
•Use Java to rewrite the following code segment using a switch statement. Do not optimize the...