Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Unusual shapes! At this point, we've gotten pretty comfortable with calculating the perimeter and area of squares and rectangles. In this assignment, we'll make
Unusual shapes! At this point, we've gotten pretty comfortable with calculating the perimeter and area of squares and rectangles. In this assignment, we'll make a program that calculates these values for regular pentagons and hexagons! Pentagon Hexagon Research the formulas to calculate the area of regular pentagons and hexagons, and implement them in your code. Hint: You can replicate exponents using multiplication. For example, r is the same as (r *r). You will likely also need to use square root. We will learn more about functions later in the course, but for now you can use the following commands. Java Math.sqrt(variable) C# Math.Sqrt (variable) C++ Sqrt (variable) Example Usage: double result = Math.sqrt( 4 ); //result will equal 2 Your task is to: A) Prompt the user to enter the necessary information to calculate the area and perimeter of a pentagon and hexagon B) Read in those values C) Perform calculations to the perimeter and area of each shape D) Display the result to the user The algorithm output is as shown below, with user input in bold. Save your source code in a file called Assignment2B (with a file extension of .cpp, .cs or .java) Sample Output: [Pentagon Calculator] Enter the length of one side: 7 Pentagon Perimeter = 35 Pentagon Area = 84.3 [Hexagon Calculator] Enter the length of one side: 9 Hexagon Perimeter = 54 Hexagon Area = 210.44
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started