Computer Applications
Convert the following switch case into if else if:
switch(x)
{
case 'T' :
case 't' : System.out.print("Teacher"); break;
default : System.out.print("Student");
}
Java Conditional Stmts
8 Likes
Answer
if (x == 'T' || x == 't') {
System.out.print("Teacher");
} else {
System.out.print("Student");
}
Answered By
4 Likes
Related Questions
Write Java expression for the following:
Evaluate the given expression when x = 4.
x *= --x + x-- + x;Write the output of the following program segment:
for(int a = 1; a <= 10; a++) { if(a % 2 == 0) continue; System.out.print(a + " "); }In the example given below of class Cat, identify the variable and the methods:
Cat Name meow() eat() play()