Question
run this code and see if it works please and thank you. Calculate.java public class Calculate { /* * polygonArea - returns the area of
run this code and see if it works please and thank you.
Calculate.java
public class Calculate { /* * polygonArea - returns the area of the polygon * @param sideCount - denotes the number of sides in the polygon * @param sideLength - denotes the length of each side in the polygon */ public static double polygonArea(int sideCount, double sideLength) { double area = sideCount * sideLength * sideLength / (Math.tan(Math.PI / sideCount)) / 4; return area; }
/* * isPrimeNumber - returns true if the passed parameter is a prime number, returns false otherwise * @param n - denotes the number to be checked */ public static boolean isPrimeNumber(long n) { if (n < 2) return false; for (int i = 2; i <= n / 2; i++) { if (n % i == 0) return false; } return true; }
/* * isPrimeNumber - returns true if the passed parameter is a prime number, returns false otherwise * @param n - denotes the number to be checked */ public static boolean isPrimeNumber(int n) { if (n < 2) return false; for (int i = 2; i <= n / 2; i++) { if (n % i == 0) return false; } return true; }
/* * main method to test other methods */ public static void main(String[] args) { int sides = 5; double length = 34.0; System.out.println("Polygon Area: " + polygonArea(sides, length));
for (int i = 0; i <= 100; i++) { if (isPrimeNumber(i)) System.out.print(i + " "); } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started