Question: write a C++ program that can number specific squares based on given start and end positions and a step size. The program should start by

write a C++ program that can number specific squares based on given start and end positions and a step size. The program should start by prompting the user for the board size (8x8 or less). Once the user enters the board dimensions, the program should display the initial board configuration with each square numbered with a one-dimensional numbering scheme. Then the program should prompt the user for the start position, end position, and the step size. You have to use validation loops to ensure that the start position is non-negative (0 or more) and the step size is positive (more than 0). Then the program should display the final board configuration with only the required squares numbered and the rest marked with **. NOTE THAT YOU MAY NOT USE ANY ARRAY IN THIS PROGRAM. The sample executions give two possible execution traces. Your program should be organized into several functions. The only code you may write in main is to declare variables and call the functions properly to achieve the overall functionality of the program. The program should have the following functions:

The getBoardSize function should have two reference type parameters for the board dimensions and will have a void return type. This function will prompt the user to enter the board size and read the number of rows and columns into the reference parameters. You will need to use a validation loop to ensure that the board size is between 1x1 and 8x8.

The printInitialBoard function should have two value type parameters for the board dimensions and will display the initial board configuration with all the squares numbered with a one-dimensional numbering scheme. This function will have a void return type.

The getStartPosition function should not have any parameter but will have an integer return type. This function will prompt the user to enter the start position, read the start position, and return that. You will need to use a validation loop to ensure that the start position is non-negative (0 or more). Look at the first sample execution trace.

The getEndPosition function should not have any parameter but will have an integer return type. This function will prompt the user to enter the end position, read the end position, and return that. You will need to use a validation loop to ensure that the end position is non-negative (0 or more).

The getStepSize function should not have any parameter but will have an integer return type. This function will prompt the user to enter the step size, read the step size, and return that. You will need to use a validation loop to ensure that the step size is positive (more than 0).

The printFinalBoard function should have five parameters two for the board dimensions, one for the start position, one for the end position, and one for the step size. This function will be responsible for displaying the final board configuration with only the required squares numbered and the rest marked with **.

Sample Executions I:

Enter the board size (rows columns): 0 5

The board size must be between 1x1 to 8x8, enter again: 10 5

The board size must be between 1x1 to 8x8, enter again: 5 5

00 01 02 03 04

05 06 07 08 09

10 11 12 13 14

15 16 17 18 19

20 21 22 23 24

Enter the start position: -1

The start position must be non-negative, enter again: -2

The start position must be non-negative, enter again: 0

Enter the end position: -3

The end position must be non-negative, enter again: 22

Enter the step size: -2

The step size must be non-negative, enter again: 3

00 ** ** 03 **

** 06 ** ** 09

** ** 12 ** **

15 ** ** 18 **

** 21 ** ** **

Sample Executions II:

Enter the board size (rows columns): 4 5

00 01 02 03 04

05 06 07 08 09

10 11 12 13 14

15 16 17 18 19

Enter the start position: 1

Enter the end position: 15

Enter the step size: 5

** 01 ** **

** ** 06 **

** ** ** 11

** ** ** **

** ** ** **

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!