monte carlo algorithm in java