

import java.math.*;

public class mc_pi {
	
   public static void main(String args[]) {

      int schritte = 10000;
      int treffer = 0;
      double radius = 1.0;
      double x, y, entfernung, pi;

      for(int i=0; i < schritte; i++) {
         x = Math.random(); 
         y = Math.random(); 
         entfernung = Math.sqrt(x*x + y*y);
         if( entfernung <= radius ) {
            treffer = treffer + 1;
         }
      }
      pi = 4 * ((double)treffer / (double)schritte);
      System.out.println(" Monte Carlo Schritte: "+ schritte);
      System.out.println(" davan Treffer: "+ treffer);
      System.out.println(" Pi: "+ pi);
   }
}

