I tried to make it simpler than using multiple if functions
importjava.util.Scanner;classMain{publicstaticvoidmain(String[]args){Scannerscan=newScanner(System.in);String[]month_name={"January","February","March","April","May","June","July","August","September","October","November","December"};System.out.println("Enter month number: ");intmonth=scan.nextInt();StringmonthName=month_name[month-1];if(month>12||month<1){System.out.println("month is not available");}else{System.out.println("Month is: "+monthName);}}}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Top comments (1)
I tried to make it simpler than using multiple if functions