write a java class to accept a month number and print the corresponding month name
Answers
Answer:
public class IfBasedSolution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter month's number: ");
int monthNumber;
monthNumber = in.nextInt();
if (monthNumber == 1)
System.out.println("January");
else if (monthNumber == 2)
System.out.println("February");
else if (monthNumber == 3)
System.out.println("March");
else if (monthNumber == 4)
System.out.println("April");
else if (monthNumber == 5)
System.out.println("May");
else if (monthNumber == 6)
System.out.println("June");