title: Blackjack game using dice
body: <p>I'm doing a project in java in which I am using dice to simulate a blackjack game, however, I have hit an area where I have written the wrong code. I'm trying to get the dealer to simulate actions if the players score is higher than his. Also my <code>checkWinner()</code> method seems to be coming active at the wrong time. I'm not asking anyone to fix it but rather tell me where the code is wrong.</p>
  
  <pre><code>public class BlackJack {
  
      static PairOfDice cards = new PairOfDice();
      static Scanner scan = new Scanner(System. in );
      static int playerScore, dealerScore, player, dealer, tempScore;
      static boolean newGame;
      static String play, hit;
  
  
      public static void main(String[] args) {
          newGame();
          dealerRoll();
          playerRoll();
  
          // checkWinner();
      }
  
      public static void newGame() {
  
          System.out.println("Would you like to play blackjack? y or n?");
          play = scan.nextLine();
  
          if (play == "y"); {
              newGame = true;
          }
          if (play != "y") newGame = false;
      }
  
      public static void dealerRoll() {
          while (newGame) {
              cards.rollDice();
          }
  
          dealerScore = (cards.rollDice());
          System.out.println("Dealer score is: " + dealerScore);
  
          if (dealerScore &lt;= 15 &amp;&amp; playerScore &gt; dealerScore) tempScore = cards.rollDice();
          System.out.println("The dice roll was: " + tempScore);
          dealerScore += tempScore;
          System.out.println("Dealer score is: " + dealerScore);
  
      }
  
      public static void playerRoll() {
          while (newGame) {
              cards.rollDice();
          }
  
          playerScore = (cards.rollDice());
  
          System.out.println("You total is " + playerScore);
  
          while (playerScore &lt; 21 || playerScore &lt; dealerScore) {
  
              System.out.println("Would you like to take a hit? y or n?");
              hit = scan.nextLine();
              if (hit.equals("y")) {
                  tempScore = cards.rollDice();
                  System.out.println("The dice roll was: " + tempScore);
                  playerScore += tempScore;
                  System.out.println("Your score is now: " + playerScore);
  
              }
              else if (hit.equals("n")); {
                  checkWinner();
              }
          }
      }
  
      public static void checkWinner() {
          if (playerScore == 21) System.out.println("You win!");
          else if (dealerScore == 21) System.out.println("Sorry, Dealer has won!");
          else if (dealerScore &gt; playerScore) System.out.println("Sorry, Dealer has won!");
          else if (playerScore &gt; dealer) System.out.println("You win!");
          else if (playerScore &gt; 21) System.out.println("Sorry you busted, Dealer has won!");
  
          else if (dealerScore &gt; 21) System.out.println("Dealer has busted, You win!");
      }
  }​
  </code></pre>