package Lecture20; public class FindPi { public static double getPi() { int count=0; for (int i=0; i < 1000000; i++) { double x= Math.random() - 0.5; double y= Math.random() - 0.5; if ((x*x + y*y) < 0.25) count++; } return 4.0*count/1000000.0; } public static void main(String[] args) { System.out.println(getPi()); System.exit(0); } }