import element.*; public class MonthTable2 { public static void main(String args[]) { ConsoleWindow c = new ConsoleWindow(); String monthName[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; int i, shortest; int daysInMonth[] = new int[12]; // or, use monthName.length // first, set all month lengths to 31 for (i = 0; i < daysInMonth.length; i++) { daysInMonth[i] = 31; } // then set the shorter month lengths daysInMonth[3] = daysInMonth[5] = daysInMonth[8] = daysInMonth[10] = 30; daysInMonth[1] = 28; c.out.println("Long months:"); for (i = 0; i < monthName.length; i++) { if (daysInMonth[i] == 31) { c.out.println(monthName[i]); } } c.out.print("A shortest month is "); shortest = 0; for (i = 1; i < 12; i++) { if (daysInMonth[i] < daysInMonth[shortest]) { shortest = i; } } c.out.println(monthName[shortest]+"."); } } /* Long months: January March May July August October December A shortest month is February. */