title: Java finding the minimum value from Scanner input always resulting in zero
body: <p>This is my first Java program. It is supposed to allow a user to enter int grades between 0 and 100. If the user enters a negative value, data entry ceases and statistics are displayed. I cannot incorporate static methods, math, or arrays.</p>
  
  <p>I am having an issue with finding the minimum grade, minGrade. Regardless of what values are entered when the program is running, minGrade always results in zero. I have been tinkering with this for a while now to no avail.</p>
  
  <p>The other issue I am having is that when I run the program, and I enter a bunch of int, but then enter some alphabet letters to test the error-checking, the program parses the user twice, instead of once.</p>
  
  <pre><code>"Please enter a numeric grade between 0 and 100, inclusive, and press Enter:"
  </code></pre>
  
  <p>The respective code is:</p>
  
  <pre><code>import java.util.Scanner;
  
  
  public class Grades {
  
      public static void main(String[] args) 
      {
          Scanner keyboard = new Scanner(System.in);
  
          System.out.println("Please enter the Course Code and and press Enter:");
          String courseCode = keyboard.nextLine();
          System.out.println("You entered: " + courseCode + "\n");
  
          int grade = 0;
  
          int numberOfGrades = 0;
          int maxGrade = 0;
          int minGrade =0;
          double avgGrade = 0;
          int sumGrades = 0;
  
          int sentinel = 0;
  
  
  
          do
  
          {
  
  
                  **System.out.println("Please enter a numeric grade between 0 and 100, inclusive, and press Enter:");**
                  while(!keyboard.hasNextInt())
                  {
  
                      System.out.println("Please enter a numeric grade between 0 and 100, inclusive, and press Enter:");
                      keyboard.nextLine();
  
                  }
  
                  grade = keyboard.nextInt();
                  if((grade &lt;=100) &amp;&amp; (grade &gt;= 0))
                  {
                      numberOfGrades++;
                      sumGrades += grade;
                      sentinel = 0;
  
                      if(maxGrade &lt; grade)
                          maxGrade = grade;
  
                      **if(minGrade &gt; grade)
                          minGrade= grade;**
                  }
                  else if(grade &gt; 100)
                  {
  
                      System.out.println("The entered number was greater than 100. Please enter a number between 0 and 100 inclusive, "
                              + "or input a negative number to exit Grade entry");
                      sentinel = 0;
                  }
                  else if(grade &lt;0)
                  {
                      grade = 0;//maybe?
                      sentinel = -1;
  
                  }
  
          }
          while((grade &gt;100) || (sentinel == 0));
  
  
          avgGrade = (sumGrades/numberOfGrades);
  
  
  
          System.out.println("You entered: " + "\ngrade: " + grade + "\n" + "sentinel: "+ sentinel +
                  "\nSum of Grades: " + sumGrades +"\nNumber of Grades: "+ numberOfGrades +"\nAverage Grades: " + avgGrade
                  + "\nMaxium Grade: "+ maxGrade+"\nMinimum Grade: "+minGrade);
      }
  
  }
  </code></pre>
  
  <p>Any input on this, the form of my code for my first java program, or anything else would be greatly appreciated.</p>
  
  <p>The last issue I am having is that the average grade always has a tenth place of zero. How can I get the tenth place to not be zero and the actual average amount?</p>