title: how can i get the total number of similar grade letters in my student grade calculator program
body: <p>My program calculates the grades of 30 students with six different scores then displays the letter grades for each student. I have done this already but my problem is how to count the number of A's, B's,C's,D's and F's.</p>
  
  <p>I want my output to be like this:</p>
  
  <p>The number of A's is:</p>
  
  <p>The number of B's is:</p>
  
  <p>The number of C's is:</p>
  
  <p>The number of D's is:</p>
  
  <p>The number of F's is:</p>
  
  <p><a href="https://i.stack.imgur.com/si9gh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/si9gh.png" alt="enter image description here"></a></p>
  
  <pre><code>import javax.swing.*;
  import java.awt.*;
  import java.io.*;
  import java.util.Scanner;
  
  public class FinalGrade extends JPanel
  {
          public static String firstName[]= new String[30];
          public static String lastName[] = new String[30];
          public static String grade[]=new String[30];
          public static int HW1;
          public static int HW2;
          public static int HW3;
          public static int Project;
          public static int Midterm;
          public static int Final;
          public static double Avg_homework;
          public static double Avg_exam;
          public static double Final_numeric_grade;
  
  
       public FinalGrade()
       {
       super(new GridLayout(1,0));
  
       String[] columnNames = {"First Name", "Last Name", "Final Grade"};
  
       Object[][] data = {
       {firstName[0], lastName[0], grade[0]},
       {firstName[1], lastName[1], grade[1]},
       {firstName[2], lastName[2], grade[2]},
       {firstName[3], lastName[3], grade[3]},
       {firstName[4], lastName[4], grade[4]},
       {firstName[5], lastName[5], grade[5]},
       {firstName[6], lastName[6], grade[6]},
       {firstName[7], lastName[7], grade[7]},
       {firstName[8], lastName[8], grade[8]},
       {firstName[9], lastName[9], grade[9]},
       {firstName[10], lastName[10], grade[10]},
       {firstName[11], lastName[11], grade[11]},
       {firstName[12], lastName[12], grade[12]},
       {firstName[13], lastName[13], grade[13]},
       {firstName[14], lastName[14], grade[14]},
       {firstName[15], lastName[15], grade[15]},
       {firstName[16], lastName[16], grade[16]},
       {firstName[17], lastName[17], grade[17]},
       {firstName[18], lastName[18], grade[18]},
       {firstName[19], lastName[19], grade[19]},
       {firstName[20], lastName[20], grade[20]},
       {firstName[21], lastName[21], grade[21]},
       {firstName[22], lastName[22], grade[22]},
       {firstName[23], lastName[23], grade[23]},
       {firstName[24], lastName[24], grade[24]},
       {firstName[25], lastName[25], grade[25]},
       {firstName[26], lastName[26], grade[26]},
       {firstName[27], lastName[27], grade[27]},
       {firstName[28], lastName[28], grade[28]},
       {firstName[29], lastName[29], grade[29]}
        };
  
       final JTable table = new JTable(data, columnNames);
  
       table.setPreferredScrollableViewportSize(new Dimension(300,400));
  
       table.setFillsViewportHeight(true);
  
       JScrollPane scrollPane = new JScrollPane(table);
       add(scrollPane);
       }
  
        private static void createAndShowGUI() {
          //Create and set up the window.
          JFrame frame = new JFrame("Grade Display");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
          //Create and set up the content pane.
          FinalGrade newContentPane = new FinalGrade();
          newContentPane.setOpaque(true); //content panes must be opaque
          frame.setContentPane(newContentPane);
  
          //Display the window.
          frame.pack();
          frame.setVisible(true);
      }
  
      public static void main(String[] args) throws FileNotFoundException
      {
          Scanner input = new Scanner (new File ("student_grades_input.txt"));
  
          int count = 0;
          while (input.hasNext())
          {
              firstName[count] = input.next();
              lastName[count] =  input.next();
              HW1 = input.nextInt();
              HW2 = input.nextInt();
              HW3 = input. nextInt();
              Project = input.nextInt();
              Midterm = input.nextInt();
              Final = input.nextInt();
  
  
              Avg_homework = (HW1 + HW2 + HW3)/3;
  
              Avg_exam = (Midterm + Final)/2;
  
  
              Final_numeric_grade = 0.45 * Avg_homework + 0.25 * Project + 0.30 * Avg_exam ;
  
              if (Final_numeric_grade &gt; 89)
  
                    grade[count] = "A";
  
  
             else if (Final_numeric_grade &gt; 79 &amp;&amp; Final_numeric_grade &lt; 90)
  
                    grade[count] = "B";
  
  
  
            else if (Final_numeric_grade &gt; 69 &amp;&amp; Final_numeric_grade &lt; 80)
  
                    grade[count] = "C";
  
  
            else if (Final_numeric_grade &gt; 59 &amp;&amp; Final_numeric_grade &lt; 70)
  
               grade[count] = "D";
  
  
              else
  
               grade[count] = "F";
  
  
              count++;
              }
  
          input.close();
          createAndShowGUI();                
  
  
      }
  
  }
  </code></pre>