So I have set up an array 'generateUser' in a method called by my main. However, when i run it, it replaces the value the index with a cumulative i value. instead of every time the dectile 7, for example, comes up it just replaces index 7 with the current value of i. i see what is wrong, but I don't know how to fix it. I think the problem line is
list[k]=++i;//HELP
public static int [] generateUser(int n)
{
//pass number of students int n;
int [] list = new int[10];
int i=0;
int total, counter, k;
int score;
String str3;
total = counter =0;
while (total < n)
{
str3 = JOptionPane.showInputDialog("Please enter the score: (1-100) ");
score = Integer.parseInt(str3);
System.out.print(str3+"\t");
if (score <1 || score >100)
{
JOptionPane.showMessageDialog(null,"The data must be betwen 1 and 100.");
}
k = (score-1)/10;
list[k]=++i;//HELP
total = counter ++;
}
return list;