/* MultiwayBranch5.java David G. Klick September 21, 2007 CIS 111 Demonstrates switch statement with fall-through (purposefully missing 'break' statements). This version takes leap years into account. No checking is done to see if the year is valid, so the user could enter a value like -50. */ public class MultiwayBranch5 extends CIS111App { public static void main(String[] args) { int days = 0; int month = getInt("What month number is it? "); int year = getInt("What year is it? "); print(month + "/" + year + " has "); switch (month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: days = 31; break; case 4: case 6: case 9: case 11: days = 30; break; case 2: if ( ((year % 4 == 0) && !(year % 100 == 0)) || (year % 400 == 0)) { days = 29; } else { days = 28; } break; default: println("*Invalid month specified*"); } if (days > 0) { println(days + " days"); } } }