title: Grade calculator program
body: <p>I'm totally stuck on this project, in which a user is supposed to enter number of students in a class, and number of exams taken. Then they enter each student's name, and then the exam scores for that student on a single line separated by blank spaces. The program calculates each student's average and the corresponding letter grade.</p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>public class proj2 {
  
   public static void main(String[] args) {
   Scanner s = new Scanner(System.in);
  
    System.out.println("Welcome to Gradecalculator!");
  
    System.out.println("Please enter the number of students:");
    int students = s.nextInt();
  
    System.out.println("Please enter the number of exams:");
    int exams = s.nextInt();
  
    int i = 0;
    int studentnumber = 1;
  
    int sum = 0;  
    while (i &lt; students) {
  
      double average = sum/exams;
  
      System.out.println("Enter student " + studentnumber++ + "'s name :");
      String studentname = s.next();
  
      System.out.println("Enter exam scores :");
  
      for (; i &lt; exams; i++) {    
       int n = s.nextInt();
       sum+=n;
  
       if (n &lt; 0) {
       System.out.println("Invalid exam scores, reenter: ");      
       }
    }
    if (average &lt;= 100 &amp;&amp; average &gt;= 90) {
         System.out.println("Letter grade: A");
         System.out.println(studentname + " gets 4 stars! ****");
        } if (average &lt;= 89 &amp;&amp; average &gt;= 80) {
         System.out.println("Letter grade: B");
         System.out.println(studentname + " gets 3 stars! ***");
        } if (average &lt;= 79 &amp;&amp; average &gt;= 70) {
         System.out.println("Letter grade: C");
         System.out.println(studentname + " gets 2 stars! **");
        } if (average &lt;= 69 &amp;&amp; average &gt;= 60) {
         System.out.println("Letter grade: D");
         System.out.println(studentname + " gets 1 star! *");
        } if (average &lt;= 59) {
         System.out.println("Letter grade: F");
         System.out.println(studentname + " gets 0 stars!");
        }
  }
   }
   }
  </code></pre>
  
  <p>This is the output I get as of now: </p>
  
  <pre class="lang-none prettyprint-override"><code>Welcome to Gradecalculator!
  </code></pre>
  
  <p>Please enter the number of students:
  3
  Please enter the number of exams:
  3
  Enter student 1's name :
  sam
  Enter exam scores :
  80 80 80
  Letter grade: F
  sam gets 0 stars!</p>
  
  <p>Obviously three 80's should be a B first of all, so I'm obviously not calculating the average properly, but I can't figure out why.</p>