/*********************************************************************
* Name:
* NetID:
* Precept:
*
* Description: Reads an integer command-line argument N and simulates
* an experience where:
* - we start with a bag containing N unpainted (numbered) balls;
* - we repeatedly pick a random ball, paint it, and put it back
* in the bag.
*
* We want to see how many balls we need to randomly pick before we get
* one that has already been previously painted.
*
* Examples:
* > java BagOfBalls 365
* 22
*********************************************************************/
public class BagOfBalls {
public static void main(String[] args) {
// number of balls
int N = _________________________________________;
// number of times we have picked a ball from the bag
int total_picked = 0;
// we will later set total_painted[k] = true if ball
// number k has been painted
_______________[] is_painted = new _______________________;
// repeat until a ball is picked that has been previously painted
while (true) {
// increment number of times we have picked a ball from the bag
total_picked _________;
// pick a random ball between 0 and N-1
int k = _________________________________________________;
// if ball number k is already painted, break out of loop
if (______________________) ____________________;
// update is_painted[] to indicate ball number k has been painted
is_painted[_____] = __________________;
}
// print result -- how many balls were picked before we picked
// the same ball a second time
System.out.println(_______________________________);
}
}