Convert the following if else statement into switch-case [2]
if(age==8)
System.out.println(“The candidate is a child”);
if(age==15)
System.out.println(“The candidate is a child”);
if(age==40)
System.out.println(“The candidate is middle aged person”);
if(age==65)
System.out.println(“The candidate is senior citizen”);
else
System.out.println(“Cannot be assessed”);
Answers
Answered by
3
Explanation:
Switch(i) {
Case 8:
System.out.println("The candidate is child") ;
Case 15:
System.out.println(“The candidate is a child”);
Case 40:
System.out.println(“The candidate is middle aged person”);
Case 65:
System.out.println(“The candidate is senior citizen”);
default:
System.out.println(“Cannot be assessed”);
}
Similar questions