Switch case advance usage

 import java.util.*;


public class weekday {

    public static void main(String[] args) {


        Scanner sc=new Scanner(System.in);

        System.out.println("Enter the number");

        int n=sc.nextInt();

        switch(n) {
            case 1,2,3,4,5:{ System.out.println("week day"); break;}

            case 6,7:{ System.out.println("week end"); break;}

            default:System.out.println("Invalid Day");
         
        }

    }
   
}

Comments

Popular posts from this blog

Convert first letter to capital letter in java

Stair case traversal search

Palindrome of string my logic