Computer Science, asked by adityaagarwal1401, 7 months ago

Rewrite the following program code using suitable if..else statement
int m, x=0;
switch(m)
{
case 0:
x=x+2;
System.out.println (“X=”+x);
break;
case 1:
x=x+4;
System.out.println("X="+x);
break;
default:
System.out.println("X"+x);
}​

Answers

Answered by amansarrafas24payxgs
0

Answer:

int m, x = 0;

if(m == 0)

{

x = x+2;

System.out.println1("X = " + x);

}

else if(m == 1)

{

x = x+4;

System.out.println("X = " + x);

}

else

{

System.out.println("X = " + x);

}

I hope you find it useful... If you have any query ask in comments I will try to solve it...

Similar questions