title: Write a program with while loop code in it to calculate the amount of exam scores enter by a user
body: <p><strong>I wrote a program for the following question in a task I'm doing.</strong></p>
  
  <p><strong>"Write a program to read a list of exam scores given as integer percentages in the range 0 to 100. Display the total number of grades and the number of grades in each letter-grade category as follows: 90-100 is A, 80-89 is B, 70-79 is C, 60-69 is D, and 0-59 is F. Use negative score as a sentinel value to indicate the end of the input."</strong></p>
  
  <p>For Example, input: 
  98,87,86,85,85,78,73,72,72,70,66,63,50,-1</p>
  
  <p>Output should be:</p>
  
  <p>Total number of grades entered was 13</p>
  
  <p>A's =1</p>
  
  <p>B's=4</p>
  
  <p>C's=5</p>
  
  <p>D's=2</p>
  
  <p>F's=1</p>
  
  <pre><code>//This is the code I wrote.// 
  import java.util.Scanner;
  public class grade
   {
  public static void main(String[] args)
   {
          int A_grades = 0;
          int B_grades = 0;
          int C_grades = 0;
          int D_grades = 0;
          int F_grades = 0;
          int count=0;
          Scanner in = new Scanner(System.in);
          System.out.println("Enter exam score as integer percentage in range 0 to 100 :");
          int score = in.nextInt();
   while(score&gt;0)
   {
         count++;
   if(score&gt;=90 &amp;&amp; score&lt;=100)
          A_grades++;
      else if(score&gt;=80 &amp;&amp; score&lt;=89)
          B_grades++;
      else if(score&gt;=70 &amp;&amp; score&lt;=79)
          C_grades++;
      else if(score&gt;=60 &amp;&amp; score&lt;=69)
          D_grades++;
      else if(score&gt;=0 &amp;&amp; score&lt;=59)
          F_grades++;
      System.out.println("Enter exam score as integer percentage in range 0 to 100 :");
   score = in.nextInt();
   } //end while
   System.out.println("Total number of grades :"+ count);
   System.out.println("Total number of A grades :"+ A_grades);
   System.out.println("Total number of B grades :"+ B_grades);
   System.out.println("Total number of C grades :"+ C_grades);
   System.out.println("Total number of D grades :"+ D_grades);
   System.out.println("Total number of F grades :"+ F_grades);
   } // end main
   } // end class
  </code></pre>
  
  <p><strong>Below is the Output of the program.</strong></p>
  
  <p>Enter exam score as integer percentage in range 0 to 100 :</p>
  
  <p>88 98 78 68 55 45 -1</p>
  
  <p>Enter exam score as integer percentage in range 0 to 100 : </p>
  
  <p>Enter exam score as integer percentage in range 0 to 100 :</p>
  
  <p>Enter exam score as integer percentage in range 0 to 100 :</p>
  
  <p>Enter exam score as integer percentage in range 0 to 100 :</p>
  
  <p>Enter exam score as integer percentage in range 0 to 100 :</p>
  
  <p>Enter exam score as integer percentage in range 0 to 100 :</p>
  
  <p>Total number of grades :6</p>
  
  <p>Total number of A grades :1</p>
  
  <p>Total number of B grades :1</p>
  
  <p>Total number of C grades :1</p>
  
  <p>Total number of D grades :1</p>
  
  <p>Total number of F grades :2</p>
  
  <p><strong>In the output it keeps repeating "Enter exam score as integer percentage in range 0 to 100 :"</strong></p>
  
  <p><strong>How can I write the code to only show it once?</strong></p>