/*********************************************************************
* Name:
* NetID:
* Precept:
*
* Description: Reads an integer command-line argument D and simulates
* the number of people with random birthdays (among D days) that enter
* a room until two share a common birthday.
*
* Examples:
* > java Birthday 365
* 22 Booksite Creative Exercise 1.4.35
*********************************************************************/
public class Birthday {
public static void main(String[] args) {
// number of days
int D = _________________________________________;
// number of people who have entered the room
int people = 0;
// We use the array of boolean days to have the following
// meaning:
//
// days[i] = "have we found someone whose birthday is i"
//
// initially, all values start as false (this is done by Java
// automatically and does not need to be programmed).
_______________[] days = new _______________________;
// repeat until two people have the same birthday
while (true) {
// increment number of people
people _________;
// random day between 0 and D-1
int d = _________________________________________________;
// if another person shares birthday d, break out of loop
if (______________________) ____________________;
// update days[] to indicate person has birthday d
days[_____] = __________________;
}
// print result -- how many people entered the room before you
// found a duplicate?
System.out.println(_______________________________);
}
}