### must be done in java problem 2 information and the code provided with it as well pro 5152670

**Must be done in Java.**

**PROBLEM 2 INFORMATION AND THE CODE PROVIDED WITH IT AS WELL.**

**PROBLEM 1 INFORMATION IF YOU NEED IT AS WELL:**

**Provide the rest of the code with full comments and explanation and with proper indentation.**

**Use simple methods for better understanding.**

**Must compile.**

**At the end, show the exact Output that's shown in Problem3.**

**CODE PROVIDED FOR PROBLEM 2:**

import java.util.Scanner;

public class Problem2

{

public static void main( String [] args )

{

//N denoting the size of the board

int n;

//B denoting the number of black pieces to be place on the board

int b;

//row and column position of a piece

int r,c;

//W denoting the number of white pieces to be place on the board

int w;

int i,j;

Scanner in = new Scanner(System.in);

n = in.nextInt();

String[][] board = new String[n][n];

//initialize the board with periods

for(i = 0;i

{

for(j = 0;j

{

board[i][j] = “.”;

}

}

//take b and its r and c positions in one line of input

//and remove any whitespaces at end and start, split at space to separate values

in.nextLine();

String[] inp = in.nextLine().trim().split(” “);

//B will the first value in the splitted input stored in the string array

b = Integer.parseInt(inp[0]);

for(i = 1;i

{

r = Integer.parseInt(inp[i]);

c = Integer.parseInt(inp[i+1]);

//check for row and column exceed conditions .

//positions must be in range of n

if(r >=0 && r

{

if(c >=0 && c

{

//set black posiiton in board

board[n – r – 1][c] = “*”;

}

}

}

//take W and its r and c positions in one line of input

//and remove any whitespaces at end and start, split at space to separate values

inp = in.nextLine().trim().split(” “);

//W will the first value in the splitted input stored in the string array

w = Integer.parseInt(inp[0]);

for(i = 1; i

{

r = Integer.parseInt(inp[i]);

c = Integer.parseInt(inp[i+1]);

//check for row and column exceed conditions .

//positions must be in range of n

if(r >=0 && r

{

if(c >=0 && c

{

//set white piece position in board

board[n – r – 1][c] = “0”;

}

}

}

// Get valid moves and modify the board accoridng to them

inp = in.nextLine().trim().split(” “);

int moveNum = Integer.parseInt(inp[0]);

for(i = 1; i

int r1, c1, r2, c2;

// read moves

r1 = Integer.parseInt(inp[i]);

c1 = Integer.parseInt(inp[i+1]);

r2 = Integer.parseInt(inp[i+2]);

c2 = Integer.parseInt(inp[i+3]);

//Move (r1,c1) to (r2, c2)

board[n-r2-1][c2] = board[n-r1-1][c1];

//Clear (r1,c1)

board[n-r1-1][c1] = “.”;

}

//finally print out the board

for(i = 0;i

{

for(j = 0;j

{

System.out.print(board[i][j]+” “);

}

System.out.println();

}

}

}

________________________________________________________________

**Show the exact Output that's shown in Problem 3. Or else it will be flagged.**

20 points! Complete this and the game is won PROBLEM 3: CHECK AND MATE! In checkers (in the first part of the game) all valid move a piece forward on a diagonal, to an empty space. Starting with your solution to Problem 2, extend it so that it takes the same input as Problem 2, but checks each move for validity is read. If an invalid move is encounte red, a message is printed out followed by the checker board, which shows all the preceding valid moves. If all the moves are valid, then the resulting checker board is displayed. C as it INPUT Sample Input Invalid move The same input as in Problem 2 4. 30 2 1 1 1 3 PROCESSING: 2 2 3 3 3 1 1 2 2 20 1 1 2 2 3 2 A move is valid if there is a checker at position R, C1, an empty space on the board at R2 C2. Furthermore, C2 C1t1, for black checkers R2 R1+1 and for white checkers R2 Rj-1 Sample Output: Invalid Move ! …0 .OUTPUT If an invalid move is encountered print “Invalid Move!” Lastly, print the resulting board (as in Problem 2), reflecting all valid moves prior to the first invalid move (or all moves if none are invalid). 30 points! Now you are well PROBLEM 2: CHECK IT OUT! on your way! In checkers, players take turns moving their pieces. Starting with your solution to Problem 1, extend it so that given a board size N, the positions of the black and white checkers, a sequence of valid moves, it prints out the resulting checker board. INPUT Sample Input One move The same input as in Problem 1, followed by Integer M denoting the number of moves, followed by 4M integers R, C, R2 C2 denoting the row and column of the start and end position 30 2 1 1 1 3 2 2 0 3 3 3 1 1 2 2 2 1 1 2 2 3 1 of a move l.e., the piece at R, c, is moved to R2 C2 Sample Output PROCESSING: *.0 You may assume that every move is valid The final board configuration is what is to be printed .0. OUTPUT Output is the same format as Problem 1 50 points! Complete this and you'll have passed! PROBLEM 1: A CHECKERED PAST Checkers is played on an N XN checker board, with one side playing the black pieces and the other side playing the white pieces. Given a board size N and the positions of the black and white checkers, create a program to print out the resulting checker board. INPUT Row, Column Integer N denoting the size of the board Integer B denoting the number of black pieces to be placed on the board, followed by B pairs of integers R C denoting the row and column of B black pieces Sample Input N Integer W denoting the number of white pieces to be placed on the board, followed by W pairs of integers R C denoting the row and column of W white pieces 4 3 2 1 1 1 3 2 2 3 3 W PROCESSING: The bottom left corner of the board is (0, o) and the top right corner is (N-1,N-1) (4,0) Sample Output 2 0 |(4,4) …0 OUTPUT 0. Output an Nx N board, where an empty square is denoted by a period ., a black piece is denoted by an asterisk *', and a white piece is denoted by the letter o' 0 2 (0,0 |(0,4)