Write a program to find the name of the month using switch statement
Answers
Answered by
153
import java.util.*;
class Hello
{
public static void main (string args [])
{
Scanner sc=new Scanner(System .in);
int d;
System.out.println("Enter a month no.");
d=sc.nextInt();
switch=(d)
{
Case1: System.out.println("January");
break;
Case2: System.out.println("February");
break;
Case3: System.out.println("March");
break;
Case4: System.out.println("April");
break;
Case5: System.out.println("May");
break;
Case6: System.out.println("June");
break;
Case7: System.out.println("July");
break;
Case8: System.out.println("August");
break;
Case9: System.out.println("September");
break;
Case10: System.out.println("October");
break;
Case11: System.out.println("November");
break;
Case12: System.out.println("December");
break;
default: System.out.println("Wrong Month");
}
}
}
Similar questions
Math,
2 months ago
French,
2 months ago
Computer Science,
5 months ago
English,
5 months ago
Political Science,
10 months ago