Netbeans
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Java Netbeans
![### Geometry: Area of a Regular Polygon
A regular polygon is an *n*-sided polygon where all sides are of the same length, and all angles are equal (i.e., the polygon is both equilateral and equiangular). The formula to calculate the area of a regular polygon is:
\[
\text{Area} = \frac{n \times s^2}{4 \times \tan\left(\frac{\pi}{n}\right)}
\]
where:
- *n* is the number of sides.
- *s* is the length of each side.
#### Task
Write a method that computes the area of a regular polygon using the following method header:
```java
public static double area(int n, double side)
```
Additionally, create a main method that asks the user to input:
- The number of sides.
- The length of one side.
Then, calculate and display the area of the polygon.
#### Sample Run
Here is an example of how the program should execute:
- **Input:**
- Number of sides: `5`
- Side length: `6.5`
- **Output:**
- The area of the polygon is `72.69017017488385`.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F2b0b34ec-95c4-43d4-bedb-36b64d2a2da3%2Fa8baf5e2-188f-4865-aa85-6db417a3582b%2Fs88pgve_processed.png&w=3840&q=75)
Transcribed Image Text:### Geometry: Area of a Regular Polygon
A regular polygon is an *n*-sided polygon where all sides are of the same length, and all angles are equal (i.e., the polygon is both equilateral and equiangular). The formula to calculate the area of a regular polygon is:
\[
\text{Area} = \frac{n \times s^2}{4 \times \tan\left(\frac{\pi}{n}\right)}
\]
where:
- *n* is the number of sides.
- *s* is the length of each side.
#### Task
Write a method that computes the area of a regular polygon using the following method header:
```java
public static double area(int n, double side)
```
Additionally, create a main method that asks the user to input:
- The number of sides.
- The length of one side.
Then, calculate and display the area of the polygon.
#### Sample Run
Here is an example of how the program should execute:
- **Input:**
- Number of sides: `5`
- Side length: `6.5`
- **Output:**
- The area of the polygon is `72.69017017488385`.
Expert Solution

Step 1
I have given java code with output below.
Step by step
Solved in 2 steps with 1 images

Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education