Write a program in Java to find out week day name using switch statement. The user enters the
day number and the program returns the day
name.
Answers
Answered by
2
Question:-
- Write a program in Java to find out week day name using switch statement. The user enters the day number and the program returns the day name.
Program:-
import java.util.*;
class Day
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter day number: ") ;
int x=sc.nextInt() ;
switch(x)
{
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("Invalid choice. Please try again later. ") ;
}
}
}
Similar questions
Physics,
2 months ago
Math,
2 months ago
Political Science,
5 months ago
Computer Science,
10 months ago