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
icon
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`.
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.

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education