Create a 3 dimensional array. The array should be initialized to zeroes. Create a program that will accept entries for ship locations. Ships will have to have the same Z value. In other words, the ships will all be horizontal. Enter a total of five ship locations. These can be between two and three element long ships. You will need to enter the ship length, starting coordinates and ending coordinates. Values of 1 will be placed in these elements. After you have entered 5 ships, then change the program to accept element positions where you are firing at the ship. If a 1 exists at the location, the print an alert showing you have struck the ship.
If all the elements occupied by the ship are hit, demonstrate by sending out 5 alerts and printing ship sunk.