Switch Case in Java.
100% Working Code and Projects.
if you need any help about project and Application Contact Shelly at:+917888361589.
Java Code :-
package CodingStartupAbheer;
import java.util.Scanner;
public class SwitchCase {
public static void main (String []Abheer)
{
Scanner Abheer1= new Scanner(System.in);
System.out.println("Enter number from 1 to 7");
int a= Abheer1.nextInt();
switch (a)
{
case 1:
System.out.println("Sunday");
break;
case 2:
System.out.println("Monday");
break;
case 3:
System.out.println("Tuesday");
break;
case 4:
System.out.println("Wednesday");
break;
case 5:
System.out.println("Thursday");
break;
case 6:
System.out.println("Friday");
break;
case 7:
System.out.println("Saturday");
break;
default:
System.out.println("Not Valid number");
break;
}
}
}
Output :-
Enter number from 1 to 7
7
Saturday
Explanation :-
In this program, when we enter number from 1 to 7 then it will directly jump to that case and execute that code which is inside the that case or block.
0 Comments:
Post a Comment