Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 2: Polygons Write a program which asks the user for the following: length of a side (can be any real number) number of sides

image text in transcribed
Problem 2: Polygons Write a program which asks the user for the following: length of a side (can be any real number) number of sides (can only be an integer) length of apothem (real number, sort of like radius for a circle) Calculate the area using the formula: area = length of side * number of sides * length of apothem/2 Since area cannot be negative, ensure all answers are positive Hint: look up absolute value in the Math Javadoc Display the result Examples (when examples are given, be sure to test each example with your code) C:\java>java Polygons C:\java>java Polygons What is the length of a side? 10.0 What is the length of a side? -3.5 How many sides? 5 How many sides? 6 Length of apothem? 5.5 Length of apothem? 3.3 Area is: 137.5 Area is: 34.65

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

Recommended Textbook for

Modern Database Management

Authors: Heikki Topi, Jeffrey A Hoffer, Ramesh Venkataraman

13th Edition

0134773659, 978-0134773650

More Books

Students also viewed these Databases questions

Question

What is linear transformation? Define with example

Answered: 1 week ago