title: Reading and validating a number with Scanner
body: <p>First of all, I have to say I'm quite new to Java.</p>
  
  <p>I need to input a <code>Double</code> value using <code>Scanner</code> and need to check whether it is within the given range. If it's within the given range it should return the value, otherwise it should ask to re-enter a new number</p>
  
  <p>I tried my best, but there are compile errors. Please tell me how I should solve this in my code.</p>
  
  <pre><code>class Find {
  
      public static void main(String args[]) {
          System.out.println(val(1, 100));
          Scanner input = new Scanner(System.in);
          double number;
          System.out.print("Enter a number: ");
          number = input.nextDouble();
      }
  
      private static String val(int minValue, int maxValue) {
          if (number &lt; minValue || number &gt; maxValue) {
              return "try again";
          } else {
              return (number);
          }
      }
  }
  </code></pre>