Assignment #94 and Month Name
Code
/// Name: Ali Kurland
/// Period: 6
/// Program Name: Month Name
/// File Name: MonthName.java
/// Date Finished:11/16/2015
public class MonthName
{
public static void main( String[] args )
{
System.out.println( "Month 1: " + monthName(1) );
System.out.println( "Month 2: " + monthName(2) );
System.out.println( "Month 3: " + monthName(3) );
System.out.println( "Month 4: " + monthName(4) );
System.out.println( "Month 5: " + monthName(5) );
System.out.println( "Month 6: " + monthName(6) );
System.out.println( "Month 7: " + monthName(7) );
System.out.println( "Month 8: " + monthName(8) );
System.out.println( "Month 9: " + monthName(9) );
System.out.println( "Month 10: " + monthName(10) );
System.out.println( "Month 11: " + monthName(11) );
System.out.println( "Month 12: " + monthName(12) );
System.out.println( "Month 43: " + monthName(43) );
}
public static String monthName( int m )
{
String outcome;
if ( m == 1 )
outcome = "January";
else if ( m == 2 )
outcome = "February";
else if ( m == 3 )
outcome = "March";
else if ( m == 4 )
outcome = "April";
else if ( m == 5 )
outcome = "May";
else if ( m == 6 )
outcome = "June";
else if ( m == 7 )
outcome = "July";
else if ( m == 8 )
outcome = "August";
else if ( m == 9 )
outcome = "September";
else if ( m == 10 )
outcome = "October";
else if ( m == 11 )
outcome = "November";
else if ( m == 12 )
outcome = "December";
else
outcome = "error";
return outcome;
}
}
Picture of the output