Question: For this project, your program is to read an input file that contains information on the placement of 4 boats into a 10x10 character array.
For this project, your program is to read an input file that contains information on the placement of 4 boats into a 10x10 character array. Each boat consists of three locations that must be hit (three elements of an array), and each boat is placed vertically or horizontally only. After placing the boats on the game board, the user is prompted for a row and column number to see if it is a hit on one of the 4 boats or a miss. Play continues until the user sinks all 4 boats. After sinking the last boat, the percentage of shots that hit is displayed followed by the final game board.
For the game board, use a 10x10 character array. This array is to be initialized to all periods (.). After initializing the array, open an input file and use the contents of the file to place the boats into the array. The input file contains 2 integer values and then a character on each line. The first integer is the row index value, the second integer is the column index value.
You should have following six user-defined functions. PrintBoard function code will be given to you. 1) InitialBoard: initialize board to all .s. 2) OpenConfigFile: Continuous prompt the user to enter the configuration input file name and open that file until it is successful. There are two exception scenarios you should deal with: empty file and bad file names. 3) PlaceBoats: places the boats into the board spaces when reading the input file. 4) BeginGame: get boats positions that user guesses to fire at. 5) CheckGame: If the guessing is correct, the spot is set to H, else X. If all three parts (three positions) of one boat has been hit, print out the boat has been sunk. Once 12 hits have been recorded, all boats have been sunk and the game is over. You should print out Congratulations!; the successful hit percentage as well as the final board.
I was given the following text file as an input:

I was also given the printboardcode to be the following

Please use the original code when answering the question. Thank you for the assistance
P01 in1 Notepad File Edit Format View Help
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
