From f89794587356b8b40a3a9c8d553189917517622a Mon Sep 17 00:00:00 2001 From: Cassandra Portlock Date: Sun, 24 Sep 2023 21:36:43 -0700 Subject: [PATCH 1/2] Completed Assignment 002 the estimate of PI --- src/ArchimedesPiMethod.java | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/ArchimedesPiMethod.java b/src/ArchimedesPiMethod.java index 0b6e780..2396271 100644 --- a/src/ArchimedesPiMethod.java +++ b/src/ArchimedesPiMethod.java @@ -1,7 +1,46 @@ +/** + * + * @author Trevor Hartman + * @author Cassandra Portlock + * + * @since Version 1.0 + * + */ import java.util.Scanner; public class ArchimedesPiMethod { public static void main(String[] args) { + Scanner scanner =new Scanner(System.in); + System.out.print("Enter number of sides for the polygon: "); + int n = scanner.nextInt(); + System.out.println("The number of sides="+n); + System.out.println(); + double B = 360.0 / n; + System.out.print("The angle of B is 360.0/"+n); + System.out.println("="+B); + System.out.println(); + + double A = B / 2; + System.out.print("The angle of A is 1/2"+B); + System.out.println("="+A); + System.out.println(); + + + double s = 2 * Math.sin(Math.toRadians(A)); + System.out.print("The length of 1 triangle base is 2*sin("+A); + System.out.println(")="+s); + System.out.println(); + + double p = n * s; + System.out.print("The perimeter is "+n); + System.out.println("*"+s); + System.out.println("="+p); + System.out.println(); + + double PI = p / 2; + System.out.print("PI is estimated as "+p); + System.out.println("/2="+PI); + System.out.println(); } } From fe38b9ae7a88698ba00c457fbd1f4decc291503f Mon Sep 17 00:00:00 2001 From: Cassandra Portlock Date: Sun, 24 Sep 2023 21:42:49 -0700 Subject: [PATCH 2/2] Completed Assignment 002 the estimate of PI --- src/ArchimedesPiMethod.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ArchimedesPiMethod.java b/src/ArchimedesPiMethod.java index 2396271..e3e2fc7 100644 --- a/src/ArchimedesPiMethod.java +++ b/src/ArchimedesPiMethod.java @@ -12,6 +12,7 @@ public class ArchimedesPiMethod { public static void main(String[] args) { Scanner scanner =new Scanner(System.in); System.out.print("Enter number of sides for the polygon: "); + int n = scanner.nextInt(); System.out.println("The number of sides="+n); System.out.println();