Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple Java stuff. :X
#1
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
Reply


Messages In This Thread
Simple Java stuff. :X - by mrcowcow - 2009-12-13, 09:35 PM
Simple Java stuff. :X - by JoeTang - 2009-12-13, 09:38 PM
Simple Java stuff. :X - by mrcowcow - 2009-12-13, 09:43 PM
Simple Java stuff. :X - by Nikkey - 2009-12-13, 09:52 PM
Simple Java stuff. :X - by mrcowcow - 2009-12-13, 10:01 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)