// BirthdayDistance.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. // A solution to exercise 11-1. import java.util.* ; class BirthdayDistance { public static void main( String[] not_in_use ) { Scanner keyboard = new Scanner( System.in ) ; Date my_birthday = new Date( "19.03.1981" ) ; System.out.print( "\n Please, type in a date in the form DD.MM.YYYY and " + "\n please use two digits for the day and month, and" + "\n four digits for the year: " ) ; String given_date_as_string = keyboard.nextLine() ; Date given_date = new Date( given_date_as_string ) ; int years_of_distance, months_of_distance, days_of_distance ; DateDistance distance_to_given_date = my_birthday.get_distance_to( given_date ) ; System.out.print( "\n\n The distance from date " + my_birthday + " to date " + given_date + " is \n " + distance_to_given_date.years + " years, " + distance_to_given_date.months + " months, and " + distance_to_given_date.days + " days" + ".\n\n" ) ; } }