01: /**
02:    This program simulates the Buffon needle experiment 
03:    and prints the resulting approximations of pi.
04: */
05: public class NeedleTester
06: {
07:    public static void main(String[] args)
08:    {
09:       Needle n = new Needle();
10:       final int TRIES1 = 10000;
11:       final int TRIES2 = 1000000;
12: 
13:       for (int i = 1; i <= TRIES1; i++)
14:          n.drop();
15:       System.out.printf("Tries = %d, Tries / Hits = %8.5f\n",
16:             TRIES1, (double) n.getTries() / n.getHits());
17: 
18:       for (int i = TRIES1 + 1; i <= TRIES2; i++)
19:          n.drop();
20:       System.out.printf("Tries = %d, Tries / Hits = %8.5f\n",
21:             TRIES2, (double) n.getTries() / n.getHits());
22:    }
23: }