1/*2 * BirthdayCalculator - a program for determining the days on3 * which people's birthdays fall in various years, and their4 * ages in those years.5 * 6 * It is a client program of both the Date and Person classes.7 */8 9import java.util.*;10 11public class BirthdayCalculator {12 /*13 * getPeople - reads in the information (name and dob) 14 * for count different people using the specified Scanner 15 * and returns an array of Person objects containing16 * that information17 */18 public static Person[] getPeople(int count, Scanner console) {19 Person[] people = new Person[count];20 21 for (int i = 0; i < count; i++) {22 System.out.println("person " + (i + 1) + ": ");23 System.out.print(" name: ");24 String name = console.nextLine();25 26 System.out.print(" date of birth (m/d/yyyy): ");27 String dobString = console.nextLine();28 String[] dobComponents = dobString.split("/");29 int month = Integer.parseInt(dobComponents[0]);30 int day = Integer.parseInt(dobComponents[1]);31 int year = Integer.parseInt(dobComponents[2]);32 33 Date dob = new Date(month, day, year);34 people[i] = new Person(name, dob);35 }36 37 return people;38 }39 40 /*41 * printBirthdays - takes an array of Person objects and42 * a year as parameters, and prints the names of the people43 * in the array, along with their birthdays and ages in the44 * specified year.45 * 46 * See the sample runs for what this method's output47 * should look like.48 */49 public static void printBirthdays(Person[] people, int year) {50 /* 51 * Replace the line below with your implementation of this52 * method. See part j of the assignment for more detail.53 */54 System.out.println("not yet implemented");55 }56 57 public static void main(String[] args) {58 Scanner console = new Scanner(System.in);59 60 /* Create a Date object for today. You don't need to understand this code.*/61 GregorianCalendar cal = new GregorianCalendar();62 Date today = new Date(cal.get(cal.MONTH) + 1, cal.get(cal.DAY_OF_MONTH), cal.get(cal.YEAR));63 64 System.out.println("Welcome to the Birthday Calculator!");65 System.out.println("Today is " + today + ".");66 System.out.println();67 68 // Get information about the people.69 System.out.print("How many people do you want to process? ");70 int numPeople = console.nextInt();71 console.nextLine();72 Person[] people = getPeople(numPeople, console);73 System.out.println();74 75 // Print out their birthdays this year.76 System.out.println("Here are their birthdays this year:");77 printBirthdays(people, today.getYear());78 System.out.println();79 80 // Print out their birthdays in some other year.81 System.out.print("Enter a year >= " + Date.MIN_YEAR + ": ");82 int otherYear = console.nextInt();83 System.out.println("Here are their birthdays in that year:");84 printBirthdays(people, otherYear);85 }86}