Not getting desired output
Hi folks
I am writing a program that makes a 100 by 100 array with low probability values (probability = 0.1) as elements. I then assign in the central region of this array higher probabilities (probability =1) in shapes of squares, triangles, and circles. Low probability areas output as 0, while high probability areas output as 1. I have gotten the desired output with triangles and squares. That is, I see 1's in shapes of squares and triangles, but the circle thing looks random, that is, no shape. I have been trying to see whats wrong but no hope. Any ideas? The problem is at case 2 in the method posted.
Note: variable rSquare is already assigned an integer value of 200 in the main method.
publicstaticvoid Probability(int s,int q1,int q2,int x,int y,int upper,int lower,double[][] array,int shape,double rSquare)
//
{//start method
//
//rSquare = Math.pow(x/20,2) + Math.pow(y/20,2);
upper = (x+q1)/2;//upper limit for the middle array (55)
lower = (y-q2)/2;//lower limit for the middle array (45)
//Assign 0.1 as probabilities of all spots
for (x = 0; x <array.length; x++){
for (y = 0; y >< array.length; y++){
array[x][y] = 0.1;
}//end for
}//end for
switch (shape){//start switch
case 1://make square
//change probability in the middle 10 by 10 box to s*0.1
for (x = lower; x <upper; x++){
for (y = lower; y ><upper; y++){
array[x][y] = s*0.1;
}//end for
}//end for
break;
case 2://make circle and change probability of circle to s*0.1
for (x=0; x ><array.length; x++){
for (y=0; y><array.length; y++){
if (Math.abs(Math.pow(((x/2)-(lower + 5)),2) + Math.pow(((y/2)-(lower + 5)),2) - rSquare)><=0){
array[x][y] = s*0.1;
}//end if
}//end for
}//end for
break;
case 3://make triangle and do as cases 1 and 2
y=lower;
int p=lower;
while (y< (lower + 10)){
for (x=p;x<lower + 10; x++){
array[x][y] = s*0.1;
}//end for
y++;
p +=1;
}//end while
break;
}//end switch
}//end method
>

