run this code and see if it works please and thank you. Calculate.java public class Calculate {
Question:
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 + " "); } } }
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang