Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem a (LA2a.java) Write a program to compute the area, perimeter, and interior angle of a regular polygon. First, have the user supply the number

Problem a (LA2a.java) Write a program to compute the area, perimeter, and interior angle of a regular polygon. First, have the user supply the number of sides of the polygon (a whole number, which must be 3 or greater) and the side length (any positive number). Then, compute the area via the following equation: where n is the number of sides and s is the side length. Note that the equations are equivalent, with the first using degrees and the second using radians. Then, compute the perimeter via the following equation: and then the interior angle (in degrees) via the following equation: So, an example run of your program would look like the following: (texts marked with blue color are the users input.) Enter number of sides: 3 Enter side length: 1 Area: 0.433 Perimeter: 3.000 Interior Angle: 60.000 degrees You should express the outputs using exactly three decimal places (rounding where necessary). Tips: (i) the Math.tan() method will compute the tangent of a value in radians, (ii) the Math.toRadians() method will convert a value in degrees to radians, and (iii) the Math.PI constant can be used for pi (). Area=s2n/4tan( 180n_)=s2n/4tan( /n ) where n is the number of sides and s is the side length. Note that the equations are equivalent, with the first using degrees and the second using radians. Then, compute the perimeter via the following equation: and then the interior angle (in degrees) via the following equation: Interior Angle = 180 360/n So, an example run of your program would look like the following: (texts marked with blue color are the users input.) Enter number of sides: 3 Enter side length: 1 Area: 0.433 Perimeter: 3.000 Interior Angle: 60.000 degrees the Math.tan() method will compute the tangent of a value in radians, (ii) the Math.toRadians() method will convert a value in degrees to radians, and (iii) the Math.PI constant can be used for pi ().

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions