title: Java - Nested While Loop
body: <p>Greetings Stack Overflow users, I come to you this evening for assistance on a Java program that I have created. I'm relatively new to Java so please excuse my ignorance on the topic. I have made a Java program that's a "Rock" "Paper" "Scissors" game and there seems to be an error in one of the statements. </p>
  
  <pre><code>import java.util.Scanner;
  
  public class TheAntlers {
  public static void main(String[] args) {
  
      int playerHumanWins = 0;
      int playerComputerWins = 0;
      int numberOfTies = 0;
      int computerResult;
  
      Scanner input = new Scanner(System.in);
  
      while(true) {
  
          String startGame;
          String playerHuman;
          String playerComputer = " ";
  
          System.out.print("Do you want to play \"Rock\", \"Paper\", \"Scissors\"? (Y/N): ");
          startGame = input.nextLine();
  
          startGame = startGame.toUpperCase();
  
          if(startGame.equals("N")) {
              System.out.println("NO!");
              break;
          }
          else if(! startGame.equals("Y")) {
              startGame = startGame.toLowerCase();
              System.out.println("Sorry, " + startGame + " is not a valid entry...");               
          }
          while(startGame.equals("Y")) {
              System.out.print("Please choose \"Rock\", \"Paper\", or \"Scissors\": ");
              playerHuman = input.nextLine();
  
              computerResult = (int)(Math.random() * 3);
  
              playerHuman = playerHuman.toUpperCase();
  
              if(computerResult == 1) {
                  playerComputer = "ROCK";
              }
              else if(computerResult == 2) {
                  playerComputer = "PAPER";
              }
              else if (computerResult == 3) {
                  playerComputer = "SCISSORS";
              }
  
              switch (playerHuman) {
                  case "ROCK" :
                      if(playerComputer.equals(playerHuman)) {
                      System.out.println("Tie you both picked \"ROCK\"");
                      numberOfTies++;
                  }
                      else if(playerComputer.equals("PAPER")) {
                          System.out.println("Computer wins!");
                          playerComputerWins++;
                      }
                      else {
                          System.out.println("You win, \"ROCK\" beats " + "\"" + playerComputer + "\"");
                          playerHumanWins++;
                          return;
                      }
                      break;
                  case "PAPER" :
                      if(playerComputer.equals(playerHuman)) {
                      System.out.println("Tie you both picked \"PAPER\"");
                      numberOfTies++;
                  }
                      else if(playerComputer.equals("ROCK")) {
                          System.out.println("You win, \"PAPER\" beats " + "\"" + playerComputer + "\"");
                          playerHumanWins++;
                          return;
                      }
                      else {
                          System.out.println("Sorry, the computer won!");
                          playerComputerWins++;
                      }
                      break;
                  case "SCISSORS" :
                      if(playerComputer.equals(playerHuman)) {
                      System.out.println("Tie you both picked \"SCISSORS\"");
                      numberOfTies++;
                  }
                      else if(playerComputer.equals("PAPER")) {
                          System.out.println("You win, \"SCISSORS\" beats " + "\"" + playerComputer + "\"");
                          playerHumanWins++;
                          return;
                      }
                      else {
                          System.out.println("Sorry, the computer won!");
                          playerComputerWins++;
                      }
                      break;
                  default:
                      playerHuman = playerHuman.toLowerCase();
                      System.out.println("Sorry, " + playerHuman + " is not a valid entry..."); 
                      break;
              } 
          }
      }         
  }
  }
  </code></pre>
  
  <p>The problem that I'm facing is related to the winning calculations. When I run the program and I enter rock repeatedly until I win, the output will be <strong>You win, "ROCK" beats " "</strong> but with any other option I get <strong>You win, "ROCK" beats "PAPER"</strong> </p>
  
  <p>My question is, why am I getting an empty callback when playing rock?</p>
  
  <p>*<em>Also if you'd be willing to point out any other suggestions to help out a novice that would be great. *</em></p>