Results 1 to 6 of 6
Thread: Array for counting from 1 to 100
 09222011, 03:25 AM #1Member
 Join Date
 Sep 2011
 Posts
 7
 Rep Power
 0
Array for counting from 1 to 100
Here's the assignment:
Write methods for the following:
a)Find and return the total sum of numbers stored in an ArrayList.
b)find and return the maximum number from the ArrayList.
c)Find and return the minimum number from the ArrayList.
d)Find and return the mean of all the numbers from the ArrayList.
Write a tester class that creates an ArrayList of numbers. Add numbers from 1 to 100 to the ArrayList. Call all the utility methods from your utility class on the ArrayList that you have created. Print the results obtained.
I don't know how to get the ArrayList to count.
here's my thoughts, but I don't know how to get it to work, it's messing up.
ArrayList<Integer> numbers = new ArrayList<Integer>();
{
for(int i=0; i<numbers.size(); i++)
{
numbers [i]=i+1;
}
 09222011, 03:55 AM #2Senior Member
 Join Date
 Apr 2010
 Location
 Philippines
 Posts
 580
 Rep Power
 7
Re: Array for counting from 1 to 100
try get() method of ArrayList.
SEE: ArrayList (Java Platform SE 6)
The Really Big Index
 09222011, 04:46 AM #3Member
 Join Date
 Sep 2011
 Posts
 7
 Rep Power
 0
Re: Array for counting from 1 to 100
Like how would I do this in code though, I don't understand Arrays at all

Re: Array for counting from 1 to 100
 09222011, 04:53 AM #5Member
 Join Date
 Sep 2011
 Posts
 7
 Rep Power
 0
Re: Array for counting from 1 to 100
the "help" he gave is a link to a crappy site that isn't helping at all, and his reply didn't answer or corrrect anything I've already posted

Re: Array for counting from 1 to 100
That "crappy" site is where many of us, myself included, learned how to code in Java. The more you use the site, the less crappy and more useful it will become and the better coder you will be. Also, you really didn't ask any direct question in your first post. It isn't really our job to correct your code, but to try guide you so that you can learn about the concepts needed to correct it yourself. Otherwise we would be cheating you out of learning something well.
Last edited by Fubarable; 09222011 at 05:09 AM.
Similar Threads

Need help with counting strings in an array.
By dalonehunter in forum New To JavaReplies: 1Last Post: 10022009, 08:47 AM 
Array help counting # of grades
By speaknspell in forum New To JavaReplies: 4Last Post: 04162009, 10:09 PM 
Incompatible types??? Counting through an array of Strings
By ookie833 in forum New To JavaReplies: 3Last Post: 12142008, 02:52 PM 
Counting Duplicate Variables in an Array
By Npcomplete in forum New To JavaReplies: 2Last Post: 10242008, 07:33 PM 
Counting the number of columns in a 2D array,
By KalEl in forum New To JavaReplies: 9Last Post: 10212008, 05:27 AM
Bookmarks