1. The position was random because there are assigned as

You need to change all those code to whatever you want.

2. There are only two balls in the code
movingballs m,s;

You need to add more and initialize each ball.
If you have more than two balls. You need a double loop to take care of collision between all balls.
e.g. ball A,B,C
You need to take care of collision between AB, BC and CA

You are welcomed to check out [url=http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=178.0]Browian motion[/url] or [url=http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=297.0]particle model for solid/liquid/gas states in 3D[/url]

3. If there is any error when compile the code, check out the error message (it will point out the line numeber where the error occur) and try to solve it according to what the message say.