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