Hi,

I am student taking a computer science course, so i was need some help. Anyway i need to find the Mode of a single dimension array. I am only allowed to find the mode using only the array that i pass into the method as a parameter. here is what i have done so far and it is not working, can you have a look and tell me where i am going wrong.

public static double findMode(int y[])
{
int mode = 0;
int counter=0, counter2=0;
for (int i=0;i<totalNumbers;i++)
{
for(int j=0; j<100; j++)
{
int temp = y;

if (temp == j)
{
counter++;
}

if(counter>counter2)
{
counter2=counter;
mode=temp;
}
}
}
return mode;
}