Question: 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
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: =++Centered hexagonal: =++Centered octagonal: =(+)Centered decagonal: =++Your code shoulddefine a main methodthat calls appropriate methods as needed. In particular, the code should:1.Generate a menufor displaying the options. Choices are: 1 Centered square number2 Centered hexagonalnumber3 Centered octagonalnumber4 Centered decagonal number Menu should be displayed using a void methodthat 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 4for 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 anif elif structure.Options1-4in the if elif structureshould include a methodcallthat performs the calculations. The corresponding method definitionshould be a value returning methodthat accepts 1 parameter and returns a value. Do NOT use global variables for your methods.oOption 1 should include a method call for centered squarenumbers. oOption 2 should include a method call for centered hexagonal number.oOption3 should include a method call for centered octagonal number.oOption 4 should include a method call for centered decagonal number.Note: NONE of your methods should promptthe user for the order number (as this would have already been done in part 3). 5.Use a loopto 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.
CODE IN PYTHON
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
