Verify if user has entered valid data type
<p>I want to check that the data entered by the user via terminal is the correct type needed in the program. If it is not, the code should loop so it asks for the data again before proceeding to the next step.</p>

<p>Example:</p>

<p>The message in terminal is as follows:</p>

<blockquote>
  <p>Enter Number:</p>
</blockquote>

<p>and the user enters a string such as </p>

<blockquote>
  <p>yes</p>
</blockquote>

<p>How can I loop the program and ask for the number again until the user enters a number of type <code>double</code>?</p>

<p>The code so far for this is:</p>

<pre><code>System.out.println("Enter number:");
double number = scanner.nextDouble();
</code></pre>
