
(Geometry: area of a pentagon) Write a
The formula for computing the area of a pentagon is

Geometry: Area of the pentagon
Program Plan:
- Import required packages.
- Declare the main class method “pentagon”.
- In the main method.
- Create an object “in1” for the scanner class.
- Get length from the user.
- Declare the required variables for area of pentagon.
- Calculate the area of the pentagon.
- Display the pentagon.
- In the main method.
The below program reads length and display the area of the pentagon.
Explanation of Solution
Program:
//import the required header files
import java.util.Scanner;
//create a class "pentagon"
public class pentagon
{
//main function
public static void main(String[] args)
{
//Create an object
Scanner in1 = new Scanner(System.in);
//Get length from user
System.out.print("Enter the length from the center to a vertex: ");
//Get the length in "double" type
double r1 = in1.nextDouble();
//Calculate "s1"
double s1 = 2 * r1 * Math.sin(Math.PI / 5);
//Calculate "a1"
double a1 = 5 * s1 * s1 / (4 * Math.tan(Math.PI / 5));
//Display "area"
System.out.println("The area of the pentagon is " +
Math.round(a1 * 100) / 100.0);
}
}
Enter the length from the center to a vertex: 5.5
The area of the pentagon is 71.92
Want to see more full solutions like this?
Chapter 4 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Additional Engineering Textbook Solutions
Problem Solving with C++ (10th Edition)
Starting Out with Python (4th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
Concepts Of Programming Languages
Degarmo's Materials And Processes In Manufacturing
Database Concepts (8th Edition)
- Discussion 1. Comment on your results. 2. Compare between the practical and theoretical results. 3. Find VB, Vc on the figure below: 3V V₁₁ R₁ B IR, R, IR, R www ΙΚΩ www www I 1.5KQ 18₁ 82002 R₁ 3.3KQ R₂ 2.2KQ E Darrow_forwardAgile1. a. Describe it and how it differs from other SDLC approachesb. List and describe the two primary terms for the agile processc. What are the three activities in the Construction phasearrow_forwardhow are youarrow_forward
- need help with thi Next, you are going to combine everything you've learned about HTML and CSS to make a static site portfolio piece. The page should first introduce yourself. The content is up to you, but should include a variety of HTML elements, not just text. This should be followed by an online (HTML-ified) version of your CV (Resume). The following is a minimum list of requirements you should have across all your content: Both pages should start with a CSS reset (imported into your CSS, not included in your HTML) Semantic use of HTML5 sectioning elements for page structure A variety other semantic HTML elements Meaningful use of Grid, Flexbox and the Box Model as appropriate for different layout components A table An image Good use of CSS Custom Properties (variables) Non-trivial use of CSS animation Use of pseudeo elements An accessible colour palette Use of media queries The focus of this course is development, not design. However, being able to replicate a provided design…arrow_forwardUsing the notationarrow_forwardyou can select multipy optionsarrow_forwardFor each of the following, decide whether the claim is True or False and select the True ones: Suppose we discover that the 3SAT can be solved in worst-case cubic time. Then it would mean that all problems in NP can also be solved in cubic time. If a problem can be solved using Dynamic Programming, then it is not NP-complete. Suppose X and Y are two NP-complete problems. Then, there must be a polynomial-time reduction from X to Y and also one from Y to X.arrow_forwardMaximum Independent Set problem is known to be NP-Complete. Suppose we have a graph G in which the maximum degree of each node is some constant c. Then, is the following greedy algorithm guaranteed to find an independent set whose size is within a constant factor of the optimal? 1) Initialize S = empty 2) Arbitrarily pick a vertex v, add v to S delete v and its neighbors from G 3) Repeat step 2 until G is empty Return S Yes Noarrow_forwardPlease help me answer this coding question in the images below for me(it is not a graded question):write the code using python and also provide the outputs requiredarrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT




