From 7b640d0e4dae0841533d4b72d9e96bc532bf2f06 Mon Sep 17 00:00:00 2001 From: Lina Date: Tue, 5 Sep 2023 20:23:06 -0700 Subject: [PATCH] Completed Java Assignment 002 --- .idea/misc.xml | 2 +- src/ArchimedesPiMethod.java | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index d15472f..ce297c6 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..b2148be 100644 --- a/src/ArchimedesPiMethod.java +++ b/src/ArchimedesPiMethod.java @@ -1,7 +1,25 @@ +/** + * + * @author Trevor Hartman + * @author Angelina Perez + * + * @since Version 1.0 + * + */ + import java.util.Scanner; public class ArchimedesPiMethod { public static void main(String[] args) { + System.out.println("Type the number of polygon sides."); + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + double b = 360.0 / n; + double a = b / 2; + double s = 2 * Math.sin(Math.toRadians(a)); + double p = n * s; + double pi = p / 2; + System.out.println(pi); } -} +} \ No newline at end of file