title: Let user input integers until "X" is pressed Java
body: <p>Basically what I have to do is read user input in (CUI) until the user presses x. Then display the min,max and average of the numbers the user has entered. I keep getting a InputMismatchException when I press x. I have tried a lot of different ways and that is why I may have some unnecessary code in there. </p>
  
  <pre><code> import java.io.*;
  import java.util.Scanner;
  import java.lang.Number;
  public class taskTwo{
  public static void main(String [] args) throws IOException {
      int min = 0;
      int max = 0;
      boolean isX =false;
      Scanner input = new Scanner (System.in);
      BufferedReader input2 = new BufferedReader (new InputStreamReader (System.in));
      String s = "x";
      s = input2.readLine();
  
  
      while(isX == false){
       if(s.equals ("x") || s.equals ("X")){
          isX = true;
      }
  
      int val = input.nextInt();
  
        if (val == 0) {
            break;
        }
        if (val &lt; min) {
            min = val;
        }
        if (val &gt; max) {
           max = val;
        }
  
        }
  
       if(isX == true){
        System.out.println("Min: " + min);
      System.out.println("Max: " + max);
        }
  
  
  
  
  }
  </code></pre>
  
  <p>}</p>