Need help with counting strings in an array.
Hey guys, as you'll see I'm kind of new to Java so I don't know too much and I came across this site looking for help. I'm making a program for my java class and the first part of the assignment is to make it take grades from a teacher and then count the number of each grade. For example, it would count 4 A's, 3 B's, 1 C, etc... The problem I have is counting the number of each letter grade in the array. This is what I have so far:
Code:
import javax.swing.JOptionPane;
public class Grading {
public static void main(String[] args) {
int a;
a=Integer.parseInt(JOptionPane.showInputDialog("How many students are in your class?"));
String grades[]=new String[a];
for(int i=0;i<grades.length;i++)
{grades[i]=JOptionPane.showInputDialog("What are their grades?");
}
So I have the person enter the number of students and than enter that many grades into an array and that works fine. The problem is counting the number of each grade. I tried using some If, else statements but to no avail. Can you guys help a noobie out? Thanks.