// Friday13.java (c) 1997-2005 Kari Laitinen // http://www.naturalprogramming.com // 2002-01-07 File created. // 2005-07-25 Last modification. // When this program is compiled, Date.java and DateDistance.java // must be in the same folder (directory) together with this file. import java.util.Scanner ; class Friday13 { public static void main( String[] not_in_use ) { Scanner keyboard = new Scanner( System.in ) ; System.out.print( "\n This program can print you a list of 10 dates" + "\n that are Fridays and 13th days of a month." + "\n Please, type in a date from which you want" + "\n the calculation to begin. Type in the date either" + "\n in form DD.MM.YYYY or in form MM/DD/YYYY and use" + "\n two digits for days and months and four digits" + "\n for the year: " ) ; String given_date_as_string = keyboard.nextLine() ; Date date_to_increment = new Date( given_date_as_string ) ; int number_of_friday13_dates_to_print = 10 ; System.out.print( "\n It is a common belief that you may have" + "\n bad luck on the following dates:\n" ) ; while ( number_of_friday13_dates_to_print > 0 ) { while ( date_to_increment.index_for_day_of_week() != 4 || date_to_increment.day() != 13 ) { date_to_increment.increment() ; } System.out.print( "\n " + date_to_increment + ", " + date_to_increment.get_day_of_week() ) ; date_to_increment.increment() ; number_of_friday13_dates_to_print -- ; } } }