using java
2d arrays
Battleship Create a program that allows the user to input coordinates onto a 5x5 2-D char array in order to locate and destroy a hidden enemy ship. 1 2 3 4 5 B D ?? Create two 5x5 character arrays. The first array will be displayed to the user and stores the hits and misses, and the second stores the solution. Initialize both filled with 's. Create the following functions: 1. placeShip - pass in the solution board. Randomize a location on the board for the upper left corner of a 2x2 set of **'s (the ship is a square). Make sure the location you choose cannot go out of bounds of the array when assigning the other 3 **'s. 2. display Board - pass in the display board, display the contents of the board to the user with 1-5 displayed above, and A-E along the side (similar to above). 3. getRow - prompt the user to enter a letter A-E (or a-e), if they enter anything else. tell them that it was an invalid input and prompt them to re-enter. Return the input as a number 0-4, where A=0,B=1, C=2, D=3, E-4. 4. getCol - prompt the user to enter a number 1-5 (you can use the Checkinput function getIntRange), then return the offset value 0-4. 5. fireShot - pass in the solution board, the display board, the row, and the column. Go to the row and column in the display board and the solution board, if the solution board has a '*', then place a *** on the display board, otherwise mark a *x' on the display board. 6. menu - display the menu options and return the user's valid choice The user fires a shot by choosing a row (A-E) and a column (1-5) (check that the spot has not already been chosen). If the shot hits the ship then a "*" is displayed to designate a 'hit', otherwise an 'x' designates a 'miss'. If the user hits all four spots of the ship, then the user wins. Reset the boards and re-randomize the ship so the user can play again. Example output of a game in progress: 1 2 3 4 5 Enter a Row(A-E): B Enter a Column(1-5): ABCDE 1 2 - - . A- - - X D- EX Menu: 1. Fire Shot 2. Quit 1 S X You Won! Battleship Create a program that allows the user to input coordinates onto a 5x5 2-D char array in order to locate and destroy a hidden enemy ship. 1 2 3 4 5 B D ?? Create two 5x5 character arrays. The first array will be displayed to the user and stores the hits and misses, and the second stores the solution. Initialize both filled with 's. Create the following functions: 1. placeShip - pass in the solution board. Randomize a location on the board for the upper left corner of a 2x2 set of **'s (the ship is a square). Make sure the location you choose cannot go out of bounds of the array when assigning the other 3 **'s. 2. display Board - pass in the display board, display the contents of the board to the user with 1-5 displayed above, and A-E along the side (similar to above). 3. getRow - prompt the user to enter a letter A-E (or a-e), if they enter anything else. tell them that it was an invalid input and prompt them to re-enter. Return the input as a number 0-4, where A=0,B=1, C=2, D=3, E-4. 4. getCol - prompt the user to enter a number 1-5 (you can use the Checkinput function getIntRange), then return the offset value 0-4. 5. fireShot - pass in the solution board, the display board, the row, and the column. Go to the row and column in the display board and the solution board, if the solution board has a '*', then place a *** on the display board, otherwise mark a *x' on the display board. 6. menu - display the menu options and return the user's valid choice The user fires a shot by choosing a row (A-E) and a column (1-5) (check that the spot has not already been chosen). If the shot hits the ship then a "*" is displayed to designate a 'hit', otherwise an 'x' designates a 'miss'. If the user hits all four spots of the ship, then the user wins. Reset the boards and re-randomize the ship so the user can play again. Example output of a game in progress: 1 2 3 4 5 Enter a Row(A-E): B Enter a Column(1-5): ABCDE 1 2 - - . A- - - X D- EX Menu: 1. Fire Shot 2. Quit 1 S X You Won