Convert the following cascaded if statement into an equivale
Convert the following cascaded if statement into an equivalent switch statement. if (hour- o) System.out. println(\" 12 midnight\"); else if (hour = 10) if(j
Solution
1)switch(hour)
{
case 0:
System.out.println(\"midnight\");
break;
case 1||2||3||4||5||6||7||8||9||10||11:
System.out.println(\"am);
break;
case 12:
System.out.println(\"12 noon\");
break;
}
2)i is less than 10 is printed because i>=10 i.e,false .so,else condition executed i is less than 10 printed.
