Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Java Programming, Comprehensive Version

Authors: Y. Daniel Liang

10th Edition

133761312, 978-0133761313

More Books

Students also viewed these Algorithms questions