title: how to do a input validation properly
body: <p>I'm trying to do a input validation for my histogram, so if a user reads in a minus number it should say Enter a positive number. For example the user enters -5, a error message pops up saying enter a positive number and then the next line says enter the next student mark which is going to be a positive number. My problem is when I enter -5 and the next line I enter is going to be a minus my code stops running, it suppose to stop at when the user enters a number that is over 100 which I declared in my while loop</p>
  
  <p><strong>This is what the result looks like:</strong></p>
  
  <p>Read in a mark</p>
  
  <p>3</p>
  
  <p>Enter the next student mark</p>
  
  <p>43</p>
  
  <p>Enter the next student mark</p>
  
  <p>-5</p>
  
  <p>Error! Enter a positive integer</p>
  
  <p>-89</p>
  
  <p>Total number of marks entered is 2</p>
  
  <p>0-29: 
  *</p>
  
  <p>30-39:</p>
  
  <p>40-69:
   *</p>
  
  <p>70-100:</p>
  
  <p><strong>This is what I expected it to look like:</strong></p>
  
  <p>Read in a mark</p>
  
  <p>-20</p>
  
  <p>Error! Enter a positive integer</p>
  
  <p>-30</p>
  
  <p>Error! Enter a positive integer</p>
  
  <p>40</p>
  
  <p>Enter the next student mark</p>
  
  <p>70</p>
  
  <p>Enter the next student mark</p>
  
  <p>-5</p>
  
  <p>Error! Enter a positive integer</p>
  
  <p>90</p>
  
  <p>Enter the next student mark</p>
  
  <p>101</p>
  
  <p>Total number of marks entered is 5</p>
  
  <p>0-29: 
  *</p>
  
  <p>30-39: 
  *</p>
  
  <p>40-69: 
  *</p>
  
  <p>70-100:
  **</p>
  
  <p>This is what I used </p>
  
  <pre><code> Scanner input = new Scanner(System.in);
  
   System.out.println("Read in a mark");
   mark = input.nextInt();
   if(mark &lt; 0) {
       System.out.println("Error! Enter a positive number"); 
       mark = input.nextInt();
   }
   while (mark &lt;= 100 &amp;&amp; mark &gt;= 0) {
  </code></pre>
  
  <p>never mind the while loop part.</p>