Question

Checkers is played on an N XN checker board, with one side playing the black pieces and the ofther side playing the white pie

please use JAVA to solve it.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The following code in java can help in doing this question.

Some points of information:

1. Scanner is used to take input from the user.

2. For using the regular convention with rows and columns (n-r-1) is done to flip the row number.

The code is as follows:

import java.util.Scanner;

public class Program{

public static void main(String []args){
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
char[][] arr = new char[n][n];
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
arr[i][j] = '.';
}
}
  
int b = scan.nextInt();
for(int i=0; i<b; i++){
int r = scan.nextInt();
int c = scan.nextInt();
arr[n - r - 1][c] = '*';
}
int w = scan.nextInt();
for(int i=0; i<w; i++){
int r = scan.nextInt();
int c = scan.nextInt();
arr[n - r - 1][c] = 'O';
}

for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
System.out.print(arr[i][j]);
}
System.out.println(' ');
}
}
}

Execution:

Input:

4 30 2 1113 22033

Output:

Output: . .0 0...

Hope this helps :)

Add a comment
Know the answer?
Add Answer to:
please use JAVA to solve it. Checkers is played on an N XN checker board, with...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Must be done in Java. PROBLEM 1 INFORMATION AND THE CODE PROVIDED WITH IT AS WELL....

    Must be done in Java. PROBLEM 1 INFORMATION AND THE CODE PROVIDED WITH 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 Problem 2. CODE PROVIDED FOR PROBLEM 1: import java.util.Scanner; public class Problem1 {    public static void main( String [] args )    {        //N denoting the size of the board        int n;       ...

  • Must be done in Java. PROBLEM 1 INFORMATION AND THE CODE PROVIDED WITH IT AS WELL....

    Must be done in Java. PROBLEM 1 INFORMATION AND THE CODE PROVIDED WITH 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 the Problem 2. CODE PROVIDED FOR PROBLEM 1: import java.util.Scanner; public class Problem1 {    public static void main( String [] args )    {        //N denoting the size of the board        int...

  • Must be done in Java. PROBLEM 2 INFORMATION AND THE CODE PROVIDED WITH IT AS WELL....

    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...

  • How to make a reversi/othello game in JAVA? Ideally with multiple classes and without GUI You...

    How to make a reversi/othello game in JAVA? Ideally with multiple classes and without GUI You are implementing a strategy board game played by two players, Black and White. It is played on an N by N board. The winner is the player who has more discs of his color than his opponent at the end of the game. This will happen when neither of the two players has a legal move or there are no spaces left on the...

  • # In this file, fill in the ... parts with lines of code. Do not # create new functions. from ran...

    # In this file, fill in the ... parts with lines of code. Do not # create new functions. from random import seed, randrange P=[" ♟♜♝♞♛♚"]; L,R,BL,TL=["▌▐▄▀"] BonR=WonR=WonB=DonR=DonB=RonB=GonR=GonB=RonG='\033[1;m\033[' WonR+='7;31;47m' # For drawing a white piece on a red background WonB+='7;30;47m' # For drawing a white piece on a black background DonR+='2;37;41m' # For drawing a dark piece on a red background DonB+='2;37;40m' # For drawing a dark piece on a black background GonR+='2;33;41m' # For drawing gold on a red...

  • Preferably in python but java is good too Task 1: Minimum Spanning Trees For this warm-up...

    Preferably in python but java is good too Task 1: Minimum Spanning Trees For this warm-up task you are to implement any efficient minimum spanning tree algorithm that takes a sequence of edge-weighted graphs and outputs the minimum cost weight of a spanning tree of each Input Format For this assignment we use adjacency matrices with positive integer weights. Here a zero entry at row i and column J indicates that no edge i] exists in the graph. The first...

  • Use C++. The game of “Jump It” consists of a board with n positive integers in...

    Use C++. The game of “Jump It” consists of a board with n positive integers in a row, except for the first column, which always contains zero. These numbers represent the cost to enter each column. Here is a sample game board where n is 6: 0 3 80 6 57 10 The object of the game is to move from the first column to the last column with the lowest total cost. The number in each column represents the...

  • Please develop the following code using C programming and using the specific functions, instructi...

    Please develop the following code using C programming and using the specific functions, instructions and format given below. Again please use the functions given especially. Also don't copy any existing solution please write your own code. This is the first part of a series of two labs (Lab 7 and Lab 8) that will complete an implementation for a board-type game called Reversi (also called Othello). The goal of this lab is to write code that sets up the input...

  • Write a class named FBoard for playing a game... PLEASE USE C++ PLEASE DO NOT USE "THIS -->". NOT ALLOWED PLE...

    Write a class named FBoard for playing a game... PLEASE USE C++ PLEASE DO NOT USE "THIS -->". NOT ALLOWED PLEASE PROVIDE COMMENTS AND OUTPUT! Write a class named FBoard for playing a game, where player x is trying to get her piece to row 7 and player o is trying to make it so player x doesn't have any legal moves. It should have: An 8x8 array of char for tracking the positions of the pieces. A data member...

  • Please write code in java You’re given a chess board with dimension n x n. There’s...

    Please write code in java You’re given a chess board with dimension n x n. There’s a king at the bottom right square of the board marked with s. The king needs to reach the top left square marked with e. The rest of the squares are labeled either with an integer p (marking a point) or with x marking an obstacle. Note that the king can move up, left and up-left (diagonal) only. Find the maximum points the king...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT