Skip to content

Instantly share code, notes, and snippets.

@pepet96
Created February 13, 2014 03:31
Show Gist options
  • Save pepet96/8969285 to your computer and use it in GitHub Desktop.
Save pepet96/8969285 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class numtomonth {
public static void main (String [] args) {
Scanner input = new Scanner(System.in);
int number = input.nextInt();
String month = stringmonth(number);
System.out.println(month);
}
public static String stringmonth(int number){
String month;
switch (number) {
case 1: month = "January";
break;
case 2: month = "February";
break;
case 3: month = "March";
break;
case 4: month = "April";
break;
case 5: month = "May";
break;
case 6: month = "June";
break;
case 7: month = "July";
break;
case 8: month = "August";
break;
case 9: month = "September";
break;
case 10: month = "October";
break;
case 11: month = "November";
break;
case 12: month = "December";
break;
default: month = "You Fail";
break;
}
return month;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment