// BirthdaysOnSunday.java Copyright (c) 2006 Kari Laitinen // http://www.naturalprogramming.com // 2006-02-15 File created. // 2006-02-15 Last modification. // When this program is compiled, Date.java and DateDistance.java // must be in the same folder (directory) together with this file. // Solution to exercise 11-4. import java.util.* ; class BirthdaysOnSunday { public static void main( String[] not_in_use ) { Scanner keyboard = new Scanner( System.in ) ; System.out.print( "\n Type in your date of birth as DD.MM.YYYY" + "\n or MM/DD/YYYY. Use four digits for the year" + "\n and two digits for the month and day: " ) ; String date_of_birth_as_string = keyboard.nextLine() ; Date date_of_birth = new Date( date_of_birth_as_string ) ; int future_year = 2006 ; int number_of_dates_printed = 0 ; while ( number_of_dates_printed < 5 ) { Date future_birthday = new Date( date_of_birth.day(), date_of_birth.month(), future_year ) ; if ( future_birthday.index_for_day_of_week() == 6 ) { System.out.print( "\n The birthday " + future_birthday + " is " + future_birthday.get_day_of_week() ) ; number_of_dates_printed ++ ; } future_year ++ ; } } }