Computer Science
Write the following statement using switch case construct.
if (a==1)
{
b += 10;
System.out.println(b);
}
else if (a == 2)
{
b -= 10;
System.out.println(b);
}
else
{
b *= a;
System.out.println(b);
}
Java Conditional Stmts
7 Likes
Answer
switch (a) {
case 1:
b += 10;
System.out.println(b);
break;
case 2:
b -= 10;
System.out.println(b);
break;
default:
b *= a;
System.out.println(b);
}
Answered By
4 Likes