2009-12-13, 09:35 PM
Alright so I have to create two methods. I've only learned basic Java so I'm kind of a dumbass at working arrays and stuff.
In my first method, I have to pass an integer into a method, and use the method to find the sum of the digits. I have no idea in hell how I'm supposed to even start doing this. :X
The second method is kind of annoying me; I can't figure out what the heck I'm doing wrong. A tester that was given to us is telling me that I did it wrong. It might be just because I don't even know how to work arrays well at all.
public double averageOfNumbers(int[] numbers)
{
double x=0;
for(int i=0; i<numbers.length; i++)
{
x += numbers[i];
}
return x;
}
Thanks in advance guys. I'm just a beginner at Java. :X
In my first method, I have to pass an integer into a method, and use the method to find the sum of the digits. I have no idea in hell how I'm supposed to even start doing this. :X
The second method is kind of annoying me; I can't figure out what the heck I'm doing wrong. A tester that was given to us is telling me that I did it wrong. It might be just because I don't even know how to work arrays well at all.
public double averageOfNumbers(int[] numbers)
{
double x=0;
for(int i=0; i<numbers.length; i++)
{
x += numbers[i];
}
return x;
}
Thanks in advance guys. I'm just a beginner at Java. :X

