#conditionalstatements #switchinjava #nestedif | basics off java|Coding for beginners
Hey guys,
in this video, we will learn how to switch statement works works
// program for printing month corresponding to the number
import java.util.Scanner;
class Hello {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Please enter month");
int month=sc.nextInt();
switch(month) {
case 1 :
System.out.println("JANUARY");
break;
case 2:
System.out.println("FEBRUARY");
break;
case 3:
System.out.println("MARCH");
break;
case 4:
System.out.println("APRIL");
break;
case 5:
System.out.println("MAY");
break;
case 6:
System.out.println("JUNE");
break;
case 7:
System.out.println("JULY");
break;
case 8:
System.out.println("AUGUST");
break;
case 9:
System.out.println("SEPTEMBER");
break;
case 10:
System.out.println("OCTOBER");
break;
case 11:
System.out.println("NOVEMBER");
break;
case 12:
System.out.println("DECEMBER");
break;
default :
System.out.println("INVALID MONTH");
break;
}
}
}
// program for checking eligibility of driving licensce
import java.util.Scanner;
class Hello {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Please enter age");
int age=sc.nextInt();
switch(age) {
case 1 :
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
System.out.println("Not eligible");
break;
default :
System.out.println("Eligible");
break;
}
}
}
Assignment Operators In Java | Java Tutorials | Coding For Beginners | Code Bode - • Assignment Operators In Java | Java T...
Type Casting In Java | Manual Vs Automatic Type Casting | Java Tutorial | Code Bode - • Type Casting In Java | Manual Vs Auto...
Operators In Java | All Operators Summarized | Java Tutorials | Code Bode - • Operators In Java | All Operators Sum...
Java interview questions| Data Types|Variables |Operators| basics off java|Coding for beginners - • Java interview questions| Data Types|...
Java Tricky Programming Questions| Data Types | Variables | Operators | Java Tutorials - • Java Tricky Programming Questions| Da...
What Are Comments In Java | Benefits Of Comments | Java Tutorials | Code Bode - • What Are Comments In Java | Benefits...
What Are Constants In Java | Benefits Of Constants | Java Tutorials | Code Bode - • What Are Constants In Java | Benefits...
Follow Us on Instagram : code.bode
For Enquiries Mail Us At : codebode@gmail.com
On this page of the site you can watch the video online Conditional Statements In Java| Switch In Java| Java Tutorials | Code Bode with a duration of hours minute second in good quality, which was uploaded by the user CodeBode 14 May 2020, share the link with friends and acquaintances, this video has already been watched 99 times on youtube and it was liked by 2 viewers. Enjoy your viewing!