Skip to content

Instantly share code, notes, and snippets.

Created August 31, 2016 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1e1faad5fa6783e0ce3addb7850cdd4b to your computer and use it in GitHub Desktop.
Save anonymous/1e1faad5fa6783e0ce3addb7850cdd4b to your computer and use it in GitHub Desktop.
Month Name #101
public class MonthName
{
public static void main( String[] args )
{
System.out.println( "Month 1: " + month_name(1) );
System.out.println( "Month 2: " + month_name(2) );
System.out.println( "Month 3: " + month_name(3) );
System.out.println( "Month 4: " + month_name(4) );
System.out.println( "Month 5: " + month_name(5) );
System.out.println( "Month 6: " + month_name(6) );
System.out.println( "Month 7: " + month_name(7) );
System.out.println( "Month 8: " + month_name(8) );
System.out.println( "Month 9: " + month_name(9) );
System.out.println( "Month 10: " + month_name(10) );
System.out.println( "Month 11: " + month_name(11) );
System.out.println( "Month 12: " + month_name(12) );
System.out.println( "Month 43: " + month_name(43) );
}
public static String month_name(int a)
{
if ( month_name == 1) { result = "Januray";}
else if ( month_name == 2) { result = "February";}
else if ( month_name == 3) { result = "March";}
else if ( month_name == 4) { result = "April";}
else if ( month_name == 5) { result = "May";}
else if ( month_name == 6) { result = "June";}
else if ( month_name == 7) { result = "July";}
else if ( month_name == 8) { result = "August";}
else if ( month_name == 9) { result = "September";}
else if ( month_name == 10) { result = "October";}
else if ( month_name == 11) { result = "November";}
else if ( month_name == 12) { result = "December";}
else { System.out.println("error");}
return result;
}
}
@KaiKyo
Copy link

KaiKyo commented Sep 1, 2016

public class MonthOffset
{
public static int month_offset( int month )
{
int result = 0;
if (month == 1) { result = 1;}
else if (month == 2) { result = 4;}
else if (month == 3) { result = 4;}
else if (month == 4) { result = 0;}
else if (month == 5) { result = 2;}
else if (month == 6) { result = 5;}
else if (month == 7) { result = 0;}
else if (month == 8) { result = 3;}
else if (month == 9) { result = 6;}
else if (month == 10) { result = 1;}
else if (month == 11) { result = 4;}
else if (month == 12) { result = 6;}
else {result = -1;}

    return result;
}


public static void main( String[] args )
{
    System.out.println( "Offset for month 1: " + month_offset(1) );
    System.out.println( "Offset for month 2: " + month_offset(2) );
    System.out.println( "Offset for month 3: " + month_offset(3) );
    System.out.println( "Offset for month 4: " + month_offset(4) );
    System.out.println( "Offset for month 5: " + month_offset(5) );
    System.out.println( "Offset for month 6: " + month_offset(6) );
    System.out.println( "Offset for month 7: " + month_offset(7) );
    System.out.println( "Offset for month 8: " + month_offset(8) );
    System.out.println( "Offset for month 9: " + month_offset(9) );
    System.out.println( "Offset for month 10: " + month_offset(10) );
    System.out.println( "Offset for month 11: " + month_offset(11) );
    System.out.println( "Offset for month 12: " + month_offset(12) );
    System.out.println( "Offset for month 43: " + month_offset(43) );
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment