/*
 * Author: Leong Lee
 * Created: Wednesday, 8 June, 2005 10:56:30
 * Modified: Wednesday, 8 June, 2005 10:56:30
 */


class ex1DisplayDays	//display all days of a year, input year
{
	public static void main(String[] arguments){
		int yearIn = 2002;
		int monthIn = 12;
		if (arguments.length > 0)   //take in main program arguments
			yearIn = Integer.parseInt(arguments[0]); // convert to Int
		
		System.out.println("Calendar of Year " + yearIn);

		for (int i=1; i<=12; i++)
		{
			System.out.println("month: " + toMonth(i));
			for (int j=1; j<=countDays(i, yearIn); j++)
			{
				System.out.print(j+ " ");	
			}
			System.out.println("");
		}
		
	}
	
	static String toMonth(int month){
		String tempMonth = "";
		switch (month){
		case 1:
			tempMonth = "January";
			break;
		case 2:
			tempMonth = "Feburary";
			break;
		case 3:
			tempMonth = "March";
			break;
		case 4:
			tempMonth = "April";
			break;
		case 5:
			tempMonth = "May";
			break;
		case 6:
			tempMonth = "June";
			break;
		case 7:
			tempMonth = "July";
			break;
		case 8:
			tempMonth = "August";
			break;
		case 9:
			tempMonth = "Septmber";
			break;
		case 10:
			tempMonth = "October";
			break;
		case 11:
			tempMonth = "November";
			break;
		case 12:
			tempMonth = "December";
			break;
		}
	return tempMonth;
	
	}
	
	static int countDays(int month, int year){  //static = class method
		int count = -1;
		switch (month) {
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			count = 31;
			break;
		case 4:
		case 6:
		case 9:
		case 11:
			count = 30;
			break;
		case 2:
			if (year % 4 == 0)
				count = 29;
			else
				count = 28;
			if ((year % 100 == 0) & (year % 400 != 0))
				count = 28;
		}
		return count;
	}

}
