Question: Write a java program that receives m and n as the number of rows and columns of the grid, respectively. In the second line, the

Write a java program that receives m and n as the number of rows and columns of the grid, respectively. In the second line, the user inputs an integer, b, showing the number of bombs placed in the grid. It then follows by b lines of input from the user, each referring to the row and column index of each one of the bombs. After receiving grid dimensions, the number of bombs, and bomb locations, you will need to display (print) the completed grid showing the bomb cells with * and safe cells with the number of neighboring bombs to that cell.

Sample Input 1:

2 2 2 0 0 1 1 

Sample Output 1:

* 2 2 * 

Sample Input 2:

5 3 4 1 2 2 2 4 0 4 1 

Sample Output 2:

0 1 1 0 2 * 0 2 * 2 3 2 * * 1 

Sample Input 3:

4 7 7 0 0 1 1 2 2 3 3 2 4 1 5 0 6 

Sample Output 3:

* 2 1 0 1 2 * 2 * 2 2 2 * 2 1 2 * 3 * 2 1 0 1 2 * 2 1 0 

Sample Input 4:

2 6 5 0 1 1 0 1 1 1 2 1 5 

Sample Output 4:

3 * 3 1 1 1 * * * 1 1 * 

Sample Input 5:

3 3 9 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 

Sample Output 5:

* * * * * * * * *

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!