import java.util.Random;

public class Buffon
{  public static void main(String[] args)
   {  Random generator = new Random();
      int hits = 0;
      final int NTRIES = 10000;
      
      for (int i = 1; i <= NTRIES; i++)
      {  // simulate needle throw
      
         double ylow = 2 * generator.nextDouble();
         double angle = 180 * generator.nextDouble();
         
         // compute high point of needle
         
         double yhigh = ylow 
            + Math.sin(Math.toRadians(angle));
         if (yhigh >= 2) hits++;
      }

      // print approximation of PI

      System.out.println("Tries / Hits = "
         + (NTRIES * 1.0) / hits);
   }
}