wap to accept a number and the day name with using switch case
Answers
Answered by
89
import java.util.*;
class Hello
{
public static void main (string args [])
{
Scanner sc=new Scanner(System .in);
int d;
System.out.println("Enter a day no.");
d=sc.nextInt();
switch=(d)
{
Case1: System.out.println("Monday");
break;
Case2: System.out.println("Tuesday");
break;
Case3: System.out.println("Wednesday");
break;
Case4: System.out.println("Thursday");
break;
Case5: System.out.println("Friday");
break;
Case6: System.out.println("Saturday");
break;
Case7: System.out.println("Sunday");
break;
default: System.out.println("Wrong Day");
}
}
}
Attachments:
Similar questions