Assignment # 95 and Month Offset
Code
/// Name: Tommy Oyuntseren
/// Period: 7
/// Program Name: MonthOffset
/// File Name: monthOffset.java
/// Date: 3/29/2016
public class MonthOffset
{
static int[] months = {1,4,4,0,2,5,0,3,6,1,4,6};
public static int monthOffset( int month )
{
if (month>0 && month < 13)
return months[month-1];
else return -1;
}
public static void main( String[] args )
{
System.out.println( "Offset for month 1: " + monthOffset(1) );
System.out.println( "Offset for month 2: " + monthOffset(2) );
System.out.println( "Offset for month 3: " + monthOffset(3) );
System.out.println( "Offset for month 4: " + monthOffset(4) );
System.out.println( "Offset for month 5: " + monthOffset(5) );
System.out.println( "Offset for month 6: " + monthOffset(6) );
System.out.println( "Offset for month 7: " + monthOffset(7) );
System.out.println( "Offset for month 8: " + monthOffset(8) );
System.out.println( "Offset for month 9: " + monthOffset(9) );
System.out.println( "Offset for month 10: " + monthOffset(10) );
System.out.println( "Offset for month 11: " + monthOffset(11) );
System.out.println( "Offset for month 12: " + monthOffset(12) );
System.out.println( "Offset for month 43: " + monthOffset(43) );
}
}
Picture of the output