Thanks to Prof Huang and Loo Kang for the codes.
I have edited the codes so that you can show a range of collision type (0: elastic to 1 perfectly inelastic)
Have used the equation provided by Ojalvo and Cohen, 1977). You can find the formula @ http://www.brachengineering.com/publications/SAE%202003-01-0491.pdf (Pg 3)
Feel free to give comments.