Is there a better way to do this?



I gave it a shot, to answer the question that that person posted here a couple of days ago

Create a java program that generates 10000 random integer numbers
between 1 and 500. Then use the generated numbers to calculate:

- the mean (average) of all numbers
- the standard deviation
- the largest and smallest number
- the median number (50% is above it, 50% is below it)
- the mode (the number(s) that occurs most frequently)

The hardest part was the "mode" part.
At first I thought I'd use arrays, but then I realized that using an ArrayList<Integer> would let me use the various methods associated with the Collections class

So I wrote my program, tested it with some small numbers. It looks ok, and when I run it with 10000 occurances of randoms 1-500 I get decent results. And it does answer the question, so I'd probably get 50% on it for sure. But is it wel written? And I don't mean comments. I mean does it follow the OO rules? I put one static method in to fill up the ArrayList of randoms, but can I take it further? Or is there a point where you've over-done it?

Anyway, here's a link to my code. I'd appreciate any comments or critisim. I think it's a good first attempt, but it's not something I'd want to turn in to a professor, yet.

http://sparklesthecat.is-a-geek.com/code/Hello.java


I know it's not a very imaginative name, but it's not going on the market.


--
John T.
My other computer is a swodniw machine
2007
.