title: Java Guessing Game count total guesses
body: <p>so I am having trouble with being able to have a proper <strong>TOTAL guess counter</strong>. </p>
  
  <p>My code needs to be basic so please dont offer me advice for doing anything you think is not trivial. 
  Currently, </p>
  
  <ol>
  <li>my code plays a game, then asks the user if they want to play again and its a simple Y or N. </li>
  <li>If yes, another games plays </li>
  <li>If no then then game ends and it reports the results of every game played as such: <code>the total games, guesses per game, and the best game (reports game that had lowest guess count)</code>. </li>
  </ol>
  
  <p>My issues are being able to accurately count <strong>ALL THE GUESSES</strong> from every game. I am able to report results and track the total games played correctly but I can't figure out how to report a result that tracks the guesses per game, adds them all up, finds the smallest one.</p>
  
  <pre><code>import java.util.*;
  
  public class GuessingGame {
    public static final int MAX = 100;
    public static void main(String[] args) {
    Scanner console = new Scanner(System.in); //to use scanner
    Random r = new Random(); //to use random numbers
  
    intro(); 
    int totalGuesses = guess(console, r); 
  
    System.out.print("Do you want to play again? ");
    String answer = console.next();
    int plays = 1;
    //while loop reads user input and determines wether 
    //or not to play the game again
    while(answer.charAt(0) == 'y' || answer.charAt(0) == 'Y') {  
       System.out.println(); 
       guess(console, r); 
       System.out.print("Do you want to play again? ");  
       answer = console.next();
       plays++;  
    } 
    System.out.println();
    results(plays, totalGuesses); 
    }     
  
        }
  
         //method that creates the guessing game and congratulatory message
       public static int guess(Scanner console, Random r) {
        System.out.println("I'm thinking of a number between one and " + MAX + "...");
          int theNumber = 50; //creates a random answer between one and the MAX       class constant
  
       int userGuess = 0;//establishes the integer for the user's guess
      int guesses = 0; //establishes the amount of guesses 
       int totalGuesses = 0;
      while(userGuess != theNumber) { //while loop that executes until answer is correct
       System.out.print("Your guess? ");
       userGuess = console.nextInt();
       if(userGuess &gt; theNumber) {
          System.out.println("It's lower.");
       } else if (userGuess &lt; theNumber) {
          System.out.println("It's higher.");
       }
       guesses++;        
    }
    if(guesses == 1) {
       System.out.println("You got it right in 1 guess!");
    } else {
       System.out.println("You got it right in " + guesses + " guesses!");
    }
    totalGuesses += guesses;
    return totalGuesses; 
     }
  
     //prints out the stats of the game
     public static void results(int plays, int totalGuesses) {
        System.out.println("Overall results:");
        System.out.println("Total games = " + plays);
        System.out.println("Total guesses = " + totalGuesses);
        System.out.println("Guesses/game = ");
        System.out.println("Best game = ");
     }
  
  }
  </code></pre>