title: Rock Paper Scissors Game Best 2 out of 3 with Loops
body: <p>The code is below. My program runs smoothly except for two issues. It does not play for just three rounds and I need it to play for just 3 rounds and determine a winner based off of whoever won at least once during the three rounds despite ties (if it comes down to that scenario randomly). It plays until there is a 2 to 1 winning ratio for either the player or the computer. I do not want it to run continuously like this. The other issue is that once a final winner is declared, the line “Enter rock, paper, or scissors” appears again, and it is not needed there. How do I go about fixing these two issues? Thank you.</p>
  
  <pre><code>import java.util.Scanner;
  import java.util.Random;
  /**
   * 
   * @author Chloe Harris
   *
   */
  public class RockPaperScissorsGame {
  
      public static void main(String[] args) {
          // TODO code application logic here
  
          //Prompt user to enter rock, paper, or scissors
          //Compare random value
          while(true){
          int wins = 0;
          int losses = 0;
          int rnd = 0;
          int USER = 0;
  
          System.out.print("Welcome to Rock Paper Scissors! Best 2 out of 3! \n"
              + "Enter \"Rock\", \"Paper\" or \"Scissors\" \n");
  
  
          // Plays 3 rounds before terminating
          while(rnd&lt;3) {
  
              Random GAME = new Random();
              int PC = 1+GAME.nextInt(3);
  
              Scanner keyboard = new Scanner (System.in);
              int SCISSOR, ROCK, PAPER;
              ROCK = 1;
              PAPER = 2;
              SCISSOR= 3;
  
              String USER_Input =  keyboard.next();
              if(USER_Input.equals("Rock"))  {
                     USER = 1;
              }
              if(USER_Input.equals("Paper")) {
                     USER = 2;
              }
              if(USER_Input.equals("Scissors")) {
                     USER = 3;
              }
  
  
  
              //If the user enters a value greater then 3 or less than 1 it will terminate the program
              //and display an error message
              while (USER &gt; 3 || USER &lt; 1) {
                  System.err.println("Incorrect value entered.");
                  System.exit(0);
                  break;
              }
  
              if(USER == PC){
                  if(USER == SCISSOR){
                      System.out.println("Scissors v Scissors! Tie!");
  
              }
                  if(USER == ROCK){
                      System.out.println("Rock v Rock! Tie!");
              }
                  if(USER == PAPER){
                      System.out.println("Paper v Paper! Tie!");
              }
                  System.out.println("Player has won " + wins + " times and the computer has won " + losses + " times");
                  System.out.print("Enter \"Rock\", \"Paper\" or \"Scissors\" \n");
              }
              //Player wins
  
              if(USER == SCISSOR)
                  if(PC == PAPER){
                  System.out.println("Scissors v Paper! Player Wins!");
                  wins++;
                  rnd++;
                  System.out.println("Player has won " + wins + " times and the computer has won " + losses + " times");
                  System.out.print("Enter \"Rock\", \"Paper\" or \"Scissors\" \n");
              }
              //Computer wins
              else if(PC == ROCK){
                  System.out.println("Scissors v Rock! Computer Wins!");
                  losses++;
                  rnd++;
                  System.out.println("Player has won " + wins + " times and the computer has won " + losses + " times");
                  System.out.print("Enter \"Rock\", \"Paper\" or \"Scissors\" \n");
              }
              //Player wins
  
              if(USER == ROCK)
                  if(PC == SCISSOR ){
                  System.out.println("Rock v Scissor! Player Wins!");
                  wins++;
                  rnd++;
                  System.out.println("Player has won " + wins + " times and the computer has won " + losses + " times");
                  System.out.print("Enter \"Rock\", \"Paper\" or \"Scissors\" \n");
              }   
              //Computer wins
              else if (PC == PAPER){
                  System.out.println("Rock v Paper! Computer Wins!");
                  losses++;
                  rnd++;
                  System.out.println("Player has won " + wins + " times and the computer has won " + losses + " times");
                  System.out.print("Enter \"Rock\", \"Paper\" or \"Scissors\" \n");
              }
  
              //Player Wins
              if(USER == PAPER)
                  if(PC == ROCK){
                  System.out.println("Paper v Rock! Player Wins!");
                  wins++;
                  rnd++;
                  System.out.println("Player has won " + wins + " times and the computer has won " + losses + " times");
                  System.out.print("Enter \"Rock\", \"Paper\" or \"Scissors\" \n");
                  }
              //Computer Wins 
              else if (PC == SCISSOR){
                  System.out.println("Paper v Scissors! Computer Wins!");
                  losses++;
                  rnd++;
                  System.out.println("Player has won " + wins + " times and the computer has won " + losses + " times");
                  System.out.print("Enter \"Rock\", \"Paper\" or \"Scissors\" \n");
              }
  
              }
  
              if(wins&gt;losses){
                  System.out.println("The Player Wins!");
              }if(losses&gt;wins){
                  System.out.println("The Computer Wins!");
              }
              System.out.println("Play again? \"Yes\" or \"No\"");
              Scanner YN = new Scanner(System.in);
  
              String YN_String = YN.next();
              if(YN_String.equals("Yes") || YN_String.equals("yes")){
              }if(YN_String.equals("No") || YN_String.equals("no")) {
                  System.out.println ("Goodbye!");
                  break;
              }
  
          }
      }
  
  }
  </code></pre>