Java with BlueJ in Hindi - Part 22

preview_player
Показать описание
Learn Java with BlueJ IDE in Hindi - Part 22
Syllabus according to Class 9 of ICSE
Chapter 7 part 5
Switch Case statements in Java
Рекомендации по теме
Комментарии
Автор

// switch case example 1

import java.util.Scanner;

public class switchcase1 {
public static void main(String[] args) {
int n;
Scanner x = new Scanner(System.in);
System.out.println("Enter a number between 1 to 4");
n = x.nextInt();

switch(n)
{
case 1:
System.out.println("Good Morning");
break;
case 2:
System.out.println("Good Afternoon");
break;
case 3:
System.out.println("Good Evening");
break;
case 4:
System.out.println("Good Night");
break;
default:
System.out.println("Wrong choice");
} } }

ComproliveHindichannel
Автор

// switch case example 2

import java.util.*;

public class switchcase2 {
public static void main(String[] args) {
char n;
Scanner x = new Scanner(System.in);
System.out.println("Enter either a, b, c or d");
n = x.next().charAt(0);

switch(n)
{
case 'a':
System.out.println("Good Morning");
break;
case 'b':
System.out.println("Good Afternoon");
break;
case 'c':
System.out.println("Good Evening");
break;
case 'd':
System.out.println("Good Night");
break;
default:
System.out.println("Wrong choice");
} } }

ComproliveHindichannel