* Write a java program to print the day (Week) by using Switch Statement.

import java.util.Scanner;

class Checkweek{

public static void main(String args[]){

Scanner sc=new Scanner(System.in);

int day;

System.out.println("Enter the any day name");

day=sc.nextInt();

switch(day){

 case 1:

     System.out.print("Monday");

     break;

 case 2:

     System.out.print("Tuesday");

     break;

 case 3:

     System.out.print("Wednestday");

     break;

 case 4:

     System.out.print("Thrusday");

     break;

 case 5:

     System.out.print("Friday");

     break;

 case 6:

     System.out.print("Staturday");

     break; 

  case 7:

     System.out.print("Sunday");

     break;

  default:

   System.out.println("Invalid day");

}

}

}


output

Enter the any day name 5 ↚

Friday.

No comments:

Post a Comment

Pages