Results 1 to 2 of 2
- 10-02-2009, 01:26 AM #1
Member
- Join Date
- Oct 2009
- Posts
- 1
- Rep Power
- 0
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:
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.Java 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?"); }
- 10-02-2009, 08:47 AM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Similar Threads
-
Array help counting # of grades
By speaknspell in forum New To JavaReplies: 4Last Post: 04-16-2009, 10:09 PM -
Incompatible types??? Counting through an array of Strings
By ookie833 in forum New To JavaReplies: 3Last Post: 12-14-2008, 01:52 PM -
Counting Duplicate Variables in an Array
By Npcomplete in forum New To JavaReplies: 2Last Post: 10-24-2008, 07:33 PM -
Counting the number of columns in a 2D array,
By KalEl in forum New To JavaReplies: 9Last Post: 10-21-2008, 05:27 AM -
Sorting an array of Strings
By Java Tip in forum java.langReplies: 0Last Post: 04-15-2008, 07:39 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks