From ff038d5a8d9179714ab897c1100ae69b277702dc Mon Sep 17 00:00:00 2001 From: 2sage4thyme <2sage4thyme@gmail.com> Date: Sat, 23 Sep 2023 14:06:38 -0700 Subject: [PATCH 1/3] Done..? *finger guns* --- .idea/misc.xml | 1 - src/ArchimedesPiMethod.java | 10 +++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index d15472f..116ab47 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - diff --git a/src/ArchimedesPiMethod.java b/src/ArchimedesPiMethod.java index 0b6e780..36bf2f2 100644 --- a/src/ArchimedesPiMethod.java +++ b/src/ArchimedesPiMethod.java @@ -2,6 +2,14 @@ public class ArchimedesPiMethod { public static void main(String[] args) { - + double n = 8.0; + double b = 360.0/n; + double A = (1.0/2.0)* b; + double s = 2.0* Math.sin(Math.toRadians(A)); + double p = n * s; + double Pi= p/ 2.0; + System.out.println(Pi); + System.out.println("I know this is wrong because Pi actually equals 3.14159 etc. But this is what I got."); + System.out.print("*finger guns*"); } } From 87789fc293ae80381ea487ff0b1c025ed6a1725d Mon Sep 17 00:00:00 2001 From: 2sage4thyme <2sage4thyme@gmail.com> Date: Sat, 23 Sep 2023 14:09:09 -0700 Subject: [PATCH 2/3] Done..? *finger guns* --- src/ArchimedesPiMethod.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ArchimedesPiMethod.java b/src/ArchimedesPiMethod.java index 36bf2f2..4468479 100644 --- a/src/ArchimedesPiMethod.java +++ b/src/ArchimedesPiMethod.java @@ -11,5 +11,6 @@ public static void main(String[] args) { System.out.println(Pi); System.out.println("I know this is wrong because Pi actually equals 3.14159 etc. But this is what I got."); System.out.print("*finger guns*"); + } } From 3606039a470265570ad823c71ea218b216d4f567 Mon Sep 17 00:00:00 2001 From: 2sage4thyme <2sage4thyme@gmail.com> Date: Wed, 27 Sep 2023 10:29:13 -0700 Subject: [PATCH 3/3] Done..? *finger guns* --- .idea/misc.xml | 3 ++- src/ArchimedesPiMethod.java | 27 ++++++++++++++++++--------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 116ab47..045943f 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,5 +1,6 @@ + - + \ No newline at end of file diff --git a/src/ArchimedesPiMethod.java b/src/ArchimedesPiMethod.java index 4468479..dd2b98b 100644 --- a/src/ArchimedesPiMethod.java +++ b/src/ArchimedesPiMethod.java @@ -2,15 +2,24 @@ public class ArchimedesPiMethod { public static void main(String[] args) { - double n = 8.0; - double b = 360.0/n; - double A = (1.0/2.0)* b; - double s = 2.0* Math.sin(Math.toRadians(A)); - double p = n * s; - double Pi= p/ 2.0; - System.out.println(Pi); - System.out.println("I know this is wrong because Pi actually equals 3.14159 etc. But this is what I got."); - System.out.print("*finger guns*"); + while (true) { + System.out.println("Please type in the number of sides"); + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + if (n < 1) { + break; + } + + double b = 360.0 / n; + double A = (1.0 / 2.0) * b; + double s = 2.0 * Math.sin(Math.toRadians(A)); + double p = n * s; + double Pi = p / 2.0; + System.out.print("My Pi estimate is "); + System.out.println(Pi); + System.out.println("The higher the number suggested, the more accurate the estimate of Pi"); + + } } }