diff --git a/.idea/misc.xml b/.idea/misc.xml index d15472f..433a737 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/src/ArchimedesPiMethod.java b/src/ArchimedesPiMethod.java index 0b6e780..f1f872d 100644 --- a/src/ArchimedesPiMethod.java +++ b/src/ArchimedesPiMethod.java @@ -2,6 +2,13 @@ public class ArchimedesPiMethod { public static void main(String[] args) { - + Scanner s = new Scanner(System.in); + System.out.print("Please enter the number of sides for a polygon: "); + int numSides = Integer.parseInt(s.nextLine()); + double B = 360.0 / numSides; + double A = B / 2; + double side = 2 * Math.sin(Math.toRadians(A)); + double p = numSides * side; + double myPI = p / 2; + System.out.printf("My estimate for PI: %.10f, myPI, Math.PI"); } -}