Question: # I need this program in Python # Please send the correct indentantion Centered Polygonal Number Menu (100 pts) Centered polygonal numbers are a series

# I need this program in Python

# Please send the correct indentantion

Centered Polygonal Number Menu (100 pts)

Centered polygonal numbers are a series of numbers in which layers of polygons can be drawn

around a centered point. Examples of centered polygons are shown below:

Figure 1: centered polygons (source: Wolfram MathWorld)

Examples of centered polygonal numbers include:

A centered square number consisting of a central dot with four dots around it, and then

additional dots in the gaps between adjacent sides. The result is a 4-sided polygon of increasing

size.

The first few centered square numbers (excluding the center dot) are:

5, 13, 25, 41, 61, 85, 113, 145, 181, 221, 265, 313, 365, 421, 481, 545, 613, 685, 761,

To get a number in this sequence, use the formula: p(n) = 2n^2 + 2n + 1

A centered hexagonal number consisting of a central dot with six dots around it, and then

additional dots in the gaps between adjacent sides. The result is a 6-sided polygon of increasing

size.

The first few centered hexagonal numbers (excluding the center dot) are:

7, 19, 37, 61, 91, 127, 169, 217, 271, 331, 397, 469, 547, 631, 721, 817, 919, 1027, 1141,

To get a number in this sequence, use the formula p(n) = 3n^2 + 3n + 1

A centered octagonal number consisting of a central dot with eight dots around it, and then

additional dots in the gaps between adjacent sides. The result is an 8-sided polygon of

increasing size.

The first few centered octagonal numbers (excluding the center dot) are:9, 25, 49, 81, 121, 169, 225, 289, 361, 441, 529, 625, 729, 841, 961, 1089, 1225, 1369,

To get a number in this sequence, use the formula p(n) = (2n+1) ^2

A centered decagonal number consisting of a central dot with ten dots around it, and then

additional dots in the gaps between adjacent sides. The result is a 10-sided polygon of

increasing size.

The first few centered decagonal numbers (excluding the center dot) are:

11, 31, 61, 101, 151, 211, 281, 361, 451, 551, 661, 781, 911, 1051, 1201, 1361, 1531, 1711,

To get a number in this sequence, use the formula p(n) = 5n^2 + 5n+ 1

Objective:

Write a program that allows the user to specify an order number (e.g. 5 for 5th). The program

should obtain the corresponding number in the centered sequence, using the formulae shown

below (all values of n 1):

Centered square: p(n) = 2n^2 + 2n+ 1

Centered hexagonal: p(n) = 3n^2 + 3n+ 1

Centered octagonal: p(n) = (2n + 1)^2

Centered decagonal: p(n) = 5n^2 + 5n+ 1

Your code should define a main method that calls appropriate methods as needed. In

particular, the code should:

1. Generate a menu for displaying the options.

Choices are: 1 Centered square number

2 Centered hexagonal number

3 Centered octagonal number

4 Centered decagonal number

Menu should be displayed using a void method that accepts no parameters

2. Ask the user to select a value (1, 2, 3, 4) that indicates their choice.

Validate the input to ensure that the user enters 1, 2, 3, or 4 for their choice. The

user should be prompted to re-enter their choice if it is not within this range.

3. Ask the user to enter an order number. Validate the input by ensuring that the user

does not enter a value less than 1.

4. The choices should be managed by an if elif structure.

Options 1-4 in the if elif structure should include a method call that performs the

calculations. The corresponding method definition should be a value returning method that accepts 1 parameter and returns a value. Do NOT use global variables

for your methods.

o Option 1 should include a method call for centered square numbers.

o Option 2 should include a method call for centered hexagonal number.

o Option 3 should include a method call for centered octagonal number.

o Option 4 should include a method call for centered decagonal number.

Note: NONE of your methods should prompt the user for the order number (as this

would have already been done in part 3).

5. Use a loop to repeat the process. The loop should be controlled by a variable that can

accept the values yes or no.

If the value is yes, the loop should repeat the program.

If the value is no, the program should display a good bye message and stop the loop.

The program should end when the value entered isnt yes.

Samples of the output are shown below. (Note, your program does not have to have the exact

wording in the output but should accomplish the same tasks.)

Welcome to the Centered Polygonal Number program!

Here are your choices:

1. Centered Square Number

2. Centered Hexagonal Number

3. Centered Octagonal Number

4. Centered Decagonal Number

Enter your choice (1 - 4): 0

Invalid entry. Re-enter your choice (1 - 4): 5

Invalid entry. Re-enter your choice (1 - 4): 1

Enter an order number (>= 1): -4

Invalid entry. Re-enter your order number (>=1): 4

The number in position 4 of the centered square series is: 41

Would you like to run the program again? Enter yes or no: yes

Welcome to the Centered Polygonal Number program!

Here are your choices:

1. Centered Square Number

2. Centered Hexagonal Number

3. Centered Octagonal Number

4. Centered Decagonal Number

Enter your choice (1 - 4): 2

Enter an order number (>= 1): 7

The number in position 7 of the centered hexagonal series is: 169

Would you like to run the program again? Enter yes or no: yes

Welcome to the Centered Polygonal Number program!

Here are your choices:1. Centered Square Number

2. Centered Hexagonal Number

3. Centered Octagonal Number

4. Centered Decagonal Number

Enter your choice (1 - 4): 3

Enter an order number (>= 1): 10

The number in position 10 of the centered octagonal series is: 441

Would you like to run the program again? Enter yes or no: yes

Welcome to the Centered Polygonal Number program!

Here are your choices:

1. Centered Square Number

2. Centered Hexagonal Number

3. Centered Octagonal Number

4. Centered Decagonal Number

Enter your choice (1 - 4): 4

Enter an order number (>= 1): 8

The number in position 8 of the centered decagonal series is: 361

Would you like to run the program again? Enter yes or no: no

Thanks for using the program! Goodbye!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!