Assignemnt #94: Month Name
Code
/// Name: Kelsey Lieberman
/// Period 5
/// Program Name: MonthName
/// File Name: MonthName.java
/// Date Finished: 1/12/2016
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 x)
{
String z;
if (x == 1)
z = "January";
else if (x == 2)
z = "February";
else if (x == 3)
z = "March";
else if (x == 4)
z = "April";
else if (x == 5)
z = "May";
else if (x == 6)
z = "June";
else if (x == 7)
z = "July";
else if (x == 8)
z = "August";
else if (x == 9)
z = "September";
else if (x == 10)
z = "October";
else if (x == 11)
z = "November";
else if (x == 12)
z = "December";
else
z = "Error";
return z;
}
}
Picture of the output