title: A and B and Chess
body: <p>I am working on the Codeforces problem "A and B and Chess", which is as follows:</p>
  
  <blockquote>
    <p>A. A and B and Chess time limit per test 1 second memory limit per
    test 256 megabytes input standard input output standard output</p>
    
    <p>A and B are preparing themselves for programming contests.</p>
    
    <p>To train their logical thinking and solve problems better, A and B
    decided to play chess. During the game A wondered whose position is
    now stronger.</p>
    
    <p>For each chess piece we know its weight:</p>
  
  <pre><code>the queen's weight is 9,
  the rook's weight is 5,
  the bishop's weight is 3,
  the knight's weight is 3,
  the pawn's weight is 1,
  the king's weight isn't considered in evaluating position. 
  </code></pre>
    
    <p>The player's weight equals to the sum of weights of all his pieces on
    the board.</p>
    
    <p>As A doesn't like counting, he asked you to help him determine which
    player has the larger position weight. Input</p>
    
    <p>The input contains eight lines, eight characters each — the board's
    description.</p>
    
    <p>The white pieces on the board are marked with uppercase letters, the
    black pieces are marked with lowercase letters.</p>
    
    <p>The white pieces are denoted as follows: the queen is represented is
    'Q', the rook — as 'R', the bishop — as'B', the knight — as 'N', the
    pawn — as 'P', the king — as 'K'.</p>
    
    <p>The black pieces are denoted as 'q', 'r', 'b', 'n', 'p', 'k',
    respectively.</p>
    
    <p>An empty square of the board is marked as '.' (a dot).</p>
    
    <p>It is not guaranteed that the given chess position can be achieved in
    a real game. Specifically, there can be an arbitrary (possibly zero)
    number pieces of each type, the king may be under attack and so on.
    Output</p>
    
    <p>Print "White" (without quotes) if the weight of the position of the
    white pieces is more than the weight of the position of the black
    pieces, print "Black" if the weight of the black pieces is more than
    the weight of the white pieces and print "Draw" if the weights of the
    white and black pieces are equal. Sample test(s)</p>
  
  <pre><code>Case 1
  
  Input
  
  ...QK...
  ........
  ........
  ........
  ........
  ........
  ........
  ...rk...
  
  Output
  
  White
  
  
  Case 2
  
  Input
  
  rnbqkbnr
  pppppppp
  ........
  ........
  ........
  ........
  PPPPPPPP
  RNBQKBNR
  
  Output
  
  Draw
  
  
  Case 3:
  
  Input
  
  rppppppr
  ...k....
  ........
  ........
  ........
  ........
  K...Q...
  ........
  
  Output
  
  Black
  </code></pre>
    
    <p>Note</p>
    
    <p>In the first test sample the weight of the position of the white
    pieces equals to 9, the weight of the position of the black pieces
    equals 5.</p>
    
    <p>In the second test sample the weights of the positions of the black
    and the white pieces are equal to 39.</p>
    
    <p>In the third test sample the weight of the position of the white
    pieces equals to 9, the weight of the position of the black pieces
    equals to 16.</p>
  </blockquote>
  
  <p>My code is:</p>
  
  <pre><code>import java.util.Scanner;
  
  public class chess {
  
  
      private final static int QUEEN = 9;
      private final static int ROOK = 5;
      private final static int BISHOP = 3;
      private final static int KNIGHT = 3;
      private final static int PAWN = 1;
      private final static int KING = 0;
  
  
      public static void main(String[] args) {
  
          int blackScore = 0;
          int whiteScore = 0;
  
          Scanner scan = new Scanner(System.in);
  
          String[] input = new String[8];
          input[0] = scan.nextLine();
          input[1] = scan.nextLine();
          input[2] = scan.nextLine();
          input[3] = scan.nextLine();
          input[4] = scan.nextLine();
          input[5] = scan.nextLine();
          input[6] = scan.nextLine();
          input[7] = scan.nextLine();
  
          for(int i = 0; i &lt; input.length; i++) {
              if(input[i].contains("Q")) {
                  whiteScore += QUEEN;
              }
  
              if(input[i].contains("R")) {
                  whiteScore += ROOK;
              }
  
              if(input[i].contains("N")) {
                  whiteScore += KNIGHT;
              }
  
              if(input[i].contains("B")) {
                  whiteScore += BISHOP;
              }
  
              if(input[i].contains("P")) {
                  whiteScore += PAWN;
              }
  
              if(input[i].contains("K")) {
                  whiteScore += KING;
              }
  
  
              if(input[i].contains("q")) {
                  blackScore += QUEEN;
              }
  
              if(input[i].contains("n")) {
                  blackScore += KNIGHT;
              }
  
              if(input[i].contains("b")) {
                  blackScore += BISHOP;
              }
  
              if(input[i].contains("p")) {
                  blackScore += PAWN;
              }
  
              if(input[i].contains("k")) {
                  blackScore += KING;
              }
  
              if(input[i].contains("r")) {
                  blackScore += ROOK;
              }    
  
  
          }
  
          if(whiteScore != blackScore) {
  
              if(blackScore &gt; whiteScore) {
                  System.out.println("Black");
              }
  
              if (whiteScore &gt; blackScore) {
                  System.out.println("White");
  
              } 
          }else {
              System.out.println("Draw");
          }    
  
  
          System.out.println(whiteScore);
          System.out.println(blackScore);
      }
  
  }
  </code></pre>
  
  <p>Can anyone explain what I've done wrong? Thanks!!</p>