Hi Friends ,
Write a blue j program to show the use of Switch statement (along with pictures).
Answers
Answered by
10
Heya ,
____________________________
____________________________
I am going to make a program of basic switch statement :-
class switchankit
{
public static void main (int n)
{
String ms;
switch (n)
{
case 1 :
ms = "Jan";
break;
case 2 :
ms = "feb";
break;
case 3 :
ms = "mar";
break;
case 4 :
ms = "april" ;
break;
case 5 :
ms= "may";
break;
case 6 :
ms = "june" ;
break;
case 7 :
ms = "july";
break;
case 8 :
ms = "august";
break;
case 9 :
ms = "september";
break;
case 10:
ms= "october" ;
break;
case 11:
ms = "november ";
break;
case 12:
ms = "december";
break;
default:
ms = "invalid month";
}
System.out.println(ms);
}
}
Hence u will get an output box ,
enter number in it and month will be displayed .
_______________________________________
_______________________________________
ANKIT
____________________________
____________________________
I am going to make a program of basic switch statement :-
class switchankit
{
public static void main (int n)
{
String ms;
switch (n)
{
case 1 :
ms = "Jan";
break;
case 2 :
ms = "feb";
break;
case 3 :
ms = "mar";
break;
case 4 :
ms = "april" ;
break;
case 5 :
ms= "may";
break;
case 6 :
ms = "june" ;
break;
case 7 :
ms = "july";
break;
case 8 :
ms = "august";
break;
case 9 :
ms = "september";
break;
case 10:
ms= "october" ;
break;
case 11:
ms = "november ";
break;
case 12:
ms = "december";
break;
default:
ms = "invalid month";
}
System.out.println(ms);
}
}
Hence u will get an output box ,
enter number in it and month will be displayed .
_______________________________________
_______________________________________
ANKIT
Attachments:
Kingsane:
Wow
Similar questions