Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

create battleship game in c++ on 10x10 grid of 0s. Put the game into a loop that

ID: 3871182 • Letter: C

Question

create battleship game in c++ on 10x10 grid of 0s.

Put the game into a loop that:

                      generates the ship placements randomly

                      allows the user to guess until they have sunk all the ships

                      prints out game statistics

                      asks the user if they want to play again

- Implement a counter to keep track of hits and misses so that can be reported out when all the ships have been sunk

- print out messages for misses, hits, and when a particular ship has been sunk (for example "You sunk my carrier" or "you hit a ship")

- Write a function that randomly places one ship of any size on the gameboard. A ship should not go over the edge of the board or cover another ship. Your function should keep looping and generating random start positions for a ship until it is successfully placed. Call this function four times. The four ships are:

       2 positions long - frigate

       3 positions long - cruiser

       4 positions long - battleship

       5 positions long - carrier

- Add a feature where before you ask the user for a guess, print out the board showing all the misses and hits so far to help the user figure out the next guess

Explanation / Answer

#include #include #include #include const int ROWS = 10; //rows const int COLUMNS = 10; //Columns int gameBoard[ROWS][ COLUMNS]; //2Dimensional Game Board array. void initializeGameBoard(); //initializes array to all 0's. void displayGameBoard(); //displays blank board as all 0's. void placeShip(); void gameOverMethodMethod(); void userInput(); void executeMove(); using namespace std; int main(int argc, char** arg) {     int rows = 0,         COLUMNS = 0;         initializeGameBoard();     displayGameBoard();     return 0; } void initializeGameBoard() {     cout