Search This Blog

If you have any problem or question please write in the comments. We will try to solve and send you the solution. Not just that we will also post your problems solution on our blog.

Monday, 13 June 2011

Using switch statement in java

import java.util.*;
class apswitch
{
public static void main (String arg[])
{
Scanner in = new Scanner (System.in);
int a;
System.out.print ("\n\t Enter the number = ");
a=in.nextInt();
switch (a)
{
case 1:
System.out.println ("\n\t One ");
break;
case 2:
System.out.println ("\n\t Two");
break;
case 3:
System.out.println ("\n\t Three");
break;
case 4:
System.out.println ("\n\t Four ");
break;
case 5:
System.out.println ("\n\t Five ");
break;
default:
System.out.println ("\n\t Out of range ");
}

}

No comments:

Post a Comment