// Friday13New.java (c) Kari Laitinen // http://www.naturalprogramming.com // 2002-01-07 Original Friday13.java was created. // 2012-11-14 Class ISODate was taken into use. // 2012-11-14 Last modification. // When this program is compiled, the file ISODate.java // must be in the same folder (directory) together with this file. import java.util.Scanner ; class Friday13New { 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" + "\n in form YYYY-MM-DD: " ) ; String given_date_as_string = keyboard.nextLine() ; ISODate date_to_increment = new ISODate( 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 -- ; } } }