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

All code within the ***...*** needs to be implemented!! Multidimensional arrays

ID: 3694424 • Letter: A

Question

All code within the ***...*** needs to be implemented!!

Multidimensional arrays. Create a project Lab12_MultArrays. Implement a program that keeps track of shots fired in a battleship game. Your program should ask the user if she wants to take another shot, ask for shot coordinates and then print the locations of all shots fired so far in a grid. Here is an example dialog:

You do not have to keep track if multiple shots were fired in the same location, i.e. you should show a single star to indicate that the shot was fired there. You do not have to join this program with previously developed battleship program.

You should store the shots in a two-dimensional array of booleans. You should use the following code as a starting point. ***http://vega.cs.kent.edu/~mikhail/classes/csi/Labs/Lab12/shotsMultArrays.cpp***

Refer to this program for multidimensional array example usage. http://vega.cs.kent.edu/~mikhail/classes/csi/Labs/Lab12/list.cpp

Explanation / Answer

CODE:

#include<iostream>
#include<fstream>

using namespace std;
//ipt function..
int ipt(istream& in=cin)
{
   int x;
   in >> x;
   return x;
}

//main function..
int main()
{
   int shot[9][9];
//multidirectional array of 9 by 9 size.


   for(int i=0; i<9; i++)
   {
       for(int j=0; j<9; j++)
       {
           //invoking function input to store ipt.
           shot[i][j] = ipt();
           }
   }

   for(int i=0; i<9; i++)
   {
       for(int j=0; j<9; j++)
       {
           cout << shot[i][j] << " ";
       }
       cout << endl;
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote