This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Array question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Array question" Watch "Array question" New topic
Author

Array question

Brusse James
Greenhorn

Joined: Nov 22, 2002
Posts: 7
Let's say I want to input (10) values into an array, and have them averaged, ok. Should I read each number in separately and them set those numbers to an array address? And is there an '.average' method? How can I make this quick and easy to follow (mostly for myself). Thanks in advance.
James Chegwidden
Author
Ranch Hand

Joined: Oct 06, 2002
Posts: 201
Use a for loop to read in numbers, use a var like sum to sum the values as you read them in and then finally divide by the number of elements.
There is no .average method. There is .length- it is not a method.


Mr. C<br /> <br />Author and Instructor<br />My book:<br /><a href="http://www.aw-bc.com/catalog/academic/product/0,1144,1576761614,00.html" target="_blank" rel="nofollow">http://www.aw-bc.com/catalog/academic/product/0,1144,1576761614,00.html</a>
Brusse James
Greenhorn

Joined: Nov 22, 2002
Posts: 7
James,
Thanks for the help. I'll give it a shot and get back to you with any further questions.
Brusse James
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Array question
 
Similar Threads
How do you add to Arrays together?
Holding threads in an array
Putting data into JTextField
question on array and printing
JComboBox Array