must be done in java input from problem 1 provide the rest of the code with full com 5152662
Must be done in Java.
INPUT FROM PROBLEM 1.
Provide the rest of the code with full comments and explanation and with proper indentation.
Use simple methods for better understanding.
Must compile.
CODE PROVIDED:
// Importing the scanner class
import java.util.Scanner;
class checkered_past
{
// Main function of the class
public static void main(String args[])
{
// creating a scanner object
Scanner scan = new Scanner(System.in);
// Getting the size of the chess board
int N = scan.nextInt();
// creating an empty chess board of size N X N
char board[][] = new char[N][N];
// Changing all the boards as empty by '.'
for(int row=0; row
{
for(int col=0; col
{
board[row][col] = '.';
}
}
// getting the number of black pieces
int black = scan.nextInt();
// array to store the positions of the pieces
int B[] = new int[2*black];
// getting the position of the black pieces
for(int i=0; i
{
B[i] = scan.nextInt();
}
// changing the postion of black pieces in the board as '*'
for(int j=0; j
{
int row = B[j];
int col = B[j+1];
board[row][col] = '*';
}
// getting the number of white pieces
int white = scan.nextInt();
// array to store the positions of the pieces
int W[] = new int[2*white];
for(int i=0; i
{
W[i] = scan.nextInt();
}
// changing the postion of black pieces in the board as 'O'
for(int j=0; j
{
int row = W[j];
int col = W[j+1];
board[row][col] = 'O';
}
// printing the board
for(int row=N-1; row >= 0; row–)
{
for(int col=0; col
{
System.out.print(board[row][col]);
}
System.out.println();
}
}
}
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 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, folllowed by W pairs of integers R C denoting the row and column of W white pieces 4 B 3 2 1 1 1 3 W 2 2 3 3 PROCESSING: ArrayList in Java ArrayList is a class in the java.util package used for lists. To create an ArrayList that stores String, we use the following ArrayList list Scanner class Scanner is a class in the java. util package Used for obtaining the inpuf of both integers and strings (amongst other types). To create an object of the Scanner class that uses the standard input stream, we use the following: Scanner stdin new Scanner (System. in ) ; With the Scanner class objects, we can use the following methods: new ArrayList ( ) ; With the ArrayList object we can use the following methods: Method Description Description Method Appends the element o to the 1ist.add (o) Returns true if there is a token end of this list. stdin.hasNext () ready in the scanner's input. (1+ nonwhitespace characters) Returns the element at the list.get (i) specified position in this list. Returns true if the next token Returns true if this list contains the specified element. list.contains (o) stdin.hasNext Int () in the scanner's input can be interpreted as an int value Returns the number of elements list.size) Finds and returns the next in this list stdin.next() token from this scanner For loop: Scans the next token of the input as an int. stdin.next Int() To iterate over values 0… n for (int i= 0; i