Jump to content

Generate random points

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
Guest_tim838_*

Guest_tim838_*
  • Guests
Hi,
I'm new to programming and am using BlueJ. I'm trying to generate n random points with [x,y] co-ords each in the range (0,1).

double[] location = new double [n];
for (i=0;i<n;i++){
location[i]=Math.random();

is what i was thinking however this does not work since i is not defined properly. I'm a little confused, any help would be appreciated.

Thanks

#2
Lop

Lop

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,172 posts
you need

for (int i=0;i<n;i++)
to make this work.

#3
falco85

falco85

    Programmer

  • Members
  • PipPipPipPip
  • 105 posts
Or declare i before the for

int i = 0;