In this program I am trying to take scores and sort them into ranges and then tell how many are in that specific range. I use row 1 to hold the scores and then row 2 to store the amount in each range.
//Declarations
int[][] scores = new int[2][26];
int x = 0;
int one = 0, two = 0, three = 0, four = 0, five = 0, six = 0, seven = 0, eight = 0;
System.out.print(scores[2][1]);
while (inFile.hasNext())
{
scores[1][x] = inFile.nextInt(); //<---- Putting the numbers into the arrayh which works fine
x++;
}
x = 0;
while (x < 20)
{
scores[2][x] = 0; //<--- Seeing if I had to populate this part of the array ???THIS IS WHERE IT ERRORS???
x++;
}
x = 0;
while (x < scores[1].length)
{
System.out.print(scores[2][x] + " "); //<--- This is me making sure that it puts zeros where I want them.
x++;
}
System.out.println();
x = 0;
while (x < scores.length)
{
if (scores[1][x] > 0 && scores[1][x] < 24)
{
scores[2][1] = one + 1;
one++;
}
else if (scores[1][x] > 25 && scores[1][x] < 49)
{
scores[2][2] = two + 1;
two++;
}
else if (scores[1][x] > 50 && scores[1][x] < 74)
{
scores[2][3] = three + 1;
three++;
}
else if (scores[1][x] > 75 && scores[1][x] < 99)
{
scores[2][4] = four + 1;
four++;
}
else if (scores[1][x] > 100 && scores[1][x] < 124)
{
scores[2][5] = five + 1;
five++;
}
else if (scores[1][x] > 125 && scores[1][x] < 149)
{
scores[2][6] = six + 1;
six++;
}
else if (scores[1][x] > 150 && scores[1][x] < 174)
{
scores[2][7] = seven + 1;
seven++;
}
else if (scores[1][x] > 175 && scores[1][x] < 200)
{
scores[2][8] = eight + 1;
eight++;
}
}
I want it to have scores[1][x] to be populated with test scores which it does and to have scores[2][x] to be first populated with zeros and then incremented to count how many scores are in each range