aboutsummaryrefslogtreecommitdiffstats
path: root/ajde.core/testdata/ReweavableTest/CalculatePI.java
diff options
context:
space:
mode:
authoraclement <aclement>2007-01-11 16:04:29 +0000
committeraclement <aclement>2007-01-11 16:04:29 +0000
commitcfd711b9628154e0b2eb2df174124699cf831f83 (patch)
tree83b9afa0e996777cf4cdcdff23f3b69f72df031b /ajde.core/testdata/ReweavableTest/CalculatePI.java
parent41fefd58f8b716468b2bdba2335eb921e5eb3a7b (diff)
downloadaspectj-cfd711b9628154e0b2eb2df174124699cf831f83.tar.gz
aspectj-cfd711b9628154e0b2eb2df174124699cf831f83.zip
new ajde.core module
Diffstat (limited to 'ajde.core/testdata/ReweavableTest/CalculatePI.java')
-rw-r--r--ajde.core/testdata/ReweavableTest/CalculatePI.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/ajde.core/testdata/ReweavableTest/CalculatePI.java b/ajde.core/testdata/ReweavableTest/CalculatePI.java
new file mode 100644
index 000000000..84ae08583
--- /dev/null
+++ b/ajde.core/testdata/ReweavableTest/CalculatePI.java
@@ -0,0 +1,26 @@
+import java.util.Random;
+
+public class CalculatePI {
+
+ static Random r = new Random();
+ static double piApproximation = 1.0f;
+ static int repetitions = 500000;
+ static int iteration = 0;
+ static double inSquare = 0;
+ static double inCircle = 0;
+
+ public static void main(String[] args) {
+ for (iteration = 0;iteration<repetitions;iteration++) approximate();
+ piApproximation = (inCircle/inSquare)*4.0f;
+ System.out.println("After "+repetitions+" iterations, pi is estimated to be "+piApproximation);
+ }
+
+ public static void approximate() {
+ double x = r.nextDouble();
+ double y = r.nextDouble();
+ inSquare++;
+ if (x*x + y*y < 1) {inCircle++;}
+ }
+
+
+} \ No newline at end of file