Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Random numbers: which should i be using?

$
0
0
hi all,

ok here is the pieve of info i have been given from my challenge:

Use random numbers to simulate dart throwing. Get two random numbers for x and y coordinates. If (x - 0.5)2 + (y - 0.5)2 < .25, then the dart landed inside the circle.

ok then so when i use

r.Next();



everything is being missed and then when i use

r.NextDouble();



everything is being hit

surely i am missing something ?

i am then supposed to get the ratio of how many hit the circle to how many were thrown and then times it by 4 to give me an estimate of pi. i have that part sorted out its just this section where the random number is either always hitting or always missing

thanks

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>