From 5cfe07c8c0886700da90a47c8b192842b97ed36f Mon Sep 17 00:00:00 2001 From: agarcia923 Date: Tue, 19 Sep 2023 12:22:54 -0700 Subject: [PATCH] Im getting the hang of it. --- .idea/misc.xml | 2 +- src/ArchimedesPiMethod.java | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index d15472f..2f755b0 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..fdf13a8 100644 --- a/src/ArchimedesPiMethod.java +++ b/src/ArchimedesPiMethod.java @@ -2,6 +2,18 @@ public class ArchimedesPiMethod { public static void main(String[] args) { - + int n = 8; + double B = 360.0 / n; + double A = 0.5 * B; + double AInRadians = Math.toRadians(A); + double s = 2 * Math.sin(AInRadians); + double p = n * s; + double piEstimate = p / 2; + System.out.println("Number of sides (n): " + n); + System.out.println("Angle B: " + B + " degrees"); + System.out.println("Angle A: " + A + " degrees"); + System.out.println("Length of 1 triangle base (s): " + s); + System.out.println("Polygon perimeter (p): " + p); + System.out.println("Estimated value of Pi (PI): " + piEstimate); } }