|
-
I can't find the mode...?
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;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks