title: Guessing Game - how to keep score
body: <p>Essentially I want to input a scoring system into my guessing game which I have currently built the code is below. Currently when the user guesses the correct number they are told their score which is currently set at 10. What I want to do is have the score set at 10 and each time a guess is incorrect that value is decreased by one. 
  I'm also having difficulty implementing a exit function while the user is playing the game. Can you folks suggest how I would go about adding these things into my code? 
  Note: I'm doing the guessing game on a server I'll just post the protocol part. </p>
  
  <p>Protocol </p>
  
  <pre><code>import java.util.*;
  
  public class KKProtocol {
      int guess = 0, number = new Random().nextInt(100) + 1;
      int score = 0;
      Scanner scan = new Scanner(System.in);
  
  
      public String processInput(String theInput) {
          String theOutput = null;
  
          System.out.println("Please guess the number between 1 and 100.");
  
          while (guess != number) {
            try {
              if ((guess = Integer.parseInt(scan.nextLine())) != number) {
                System.out.println(guess &lt; number ? "Higher..." : "Lower...");
              }
              else {
                System.out.println("Correct!");
                score = 1;
              }
            }   
            catch (NumberFormatException e) {
              System.out.println("Please enter a valid number! If you want to Quit just say'Goodbye'");
            }   
  
          }   
  
  
  
          return theOutput;   
      }
  }
  </code></pre>