There is some mistake in the formula in the earlier post. I have corrected in this version.
It seems that I can't get a perfect value of final velocity based on the coefficient of restitution. I suspect this is due to the modelling equation.
Thank to Prof Hwang and Loo Kang again for the codes.