title: How to restrict input from user to a numeric value?
body: <p>I've been searching on the internet and can't seem to find this answer
  So does anyone know to how stop users from inputting letters where only numbers should be allowed? </p>
  
  <p>This is what my code looks like so far. </p>
  
  <pre><code>public static double payCalculator(double hours, double basePay)
  {
      double totalPay; 
      double overTime = 8.00 * 1.5;
      while(hours &lt; 0 | hours &gt; 60) {
          System.out.println("Cannot work more than 60 hours a week");
          System.out.println("Hours Work?");
          hours = in.nextDouble();
      }
      while(basePay &lt; 8) {
          System.out.println("Base Pay cannot be less than 8");
          System.out.println("Base Pay?");
          basePay = in.nextDouble();
      }
      if 
          (hours &lt;= 40){
          totalPay = hours*basePay;
      }
      else {
          totalPay = ((hours - 40)*overTime) + (40*basePay);
      }
      return totalPay;
  
  }
  public static void main (String[] args) {
  
      System.out.println("Hours worked?");
      hours = in.nextDouble();
      System.out.println("Base Pay?");
      basePay = in.nextDouble();
      DecimalFormat df = new DecimalFormat("###.##");
      totalPay = payCalculator(hours, basePay);
      System.out.println("Total Pay is " + df.format(totalPay));       
  }
  }
  </code></pre>
  
  <p>Thank you for your time. </p>