(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
MyLab Programming with Pearson eText -- Access Card -- for Introduction to Java Programming and Data Structures, Comprehensive Version
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)
- make a screen capture showing the StegExpose resultsarrow_forwardWhich of the following is not one of the recommended criteria for strategic objectives? Multiple Choice a) realistic b) appropriate c) sustainable d) measurablearrow_forwardManagement innovations such as total quality, benchmarking, and business process reengineering always lead to sustainable competitive advantage because everyone else is doing them. a) True b) Falsearrow_forward
- Vision statements are more specific than strategic objectives. a) True b) Falsearrow_forwardThe three components of the __________ approach to corporate accounting include financial, environmental, and social performance measures. Multiple Choice a) stakeholder b) triple dimension c) triple bottom line d) triple efficiencyarrow_forwardCompetitors, as internal stakeholders, should be included in the stakeholder management consideration of a company and in its mission statement. a) True b) Falsearrow_forward
- At what level in the organization should the strategic management perspective be emphasized? Multiple Choice a) throughout the organization b) from the bottom up in an organization c) at the top of the organization d) at the middle of the organizationarrow_forwardA good manager can be flexible when it comes to sticking to the original plan; to get good results, the intended strategy has to become the realized strategy. a) True b) Falsearrow_forward________ tend to be quite enduring and seldom change. Multiple Choice a) Strategic objectives b) Vision statements c) Strategic plans d) Mission statementsarrow_forward
- The idea that organizations are not only accountable to stockholders but also to the community-at-large is known as social responsibility. a) True b) Falsearrow_forwardAmong the leaders needed for an effective strategic management process are ________, who, although they have little positional power and formal authority, generate their power through the conviction and clarity of their ideas. Multiple Choice a) executive leaders b) triple bottom line advocates c) internal networkers d) local line leadersarrow_forwardI would like to get help to resolve the following casearrow_forward
- 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