/** MonthNumbers.java reads a 1-12 number and displays 
 *   the three-letter abbreviation of the corresponding month.
 * 
 * @author Joel Adams, for Alice+Java
 */

import java.util.Scanner;

public class MonthAbbreviations {
  public static void main(String[] args) {
	// get the month number
    System.out.println("To see the first three letters of a month,");
    System.out.print(" enter a month-number (1-12): ");
    Scanner kbd = new Scanner(System.in);		
    int monthNumber = kbd.nextInt();
    // compute the month abbreviation
    final String monthTable = "JanFebMarAprMayJunJulAugSepOctNovDec";
    int start = (monthNumber - 1) * 3;
    int stop = start + 3;
    String monthAbbrev = monthTable.substring(start, stop);
    // display the month abbreviation
    System.out.println("\nMonth #" + monthNumber + 
                        " begins with '" + monthAbbrev + "'.");
  }
}
