# How to convert this pseudo code into JAVA

• March 2nd, 2013, 08:31 AM
MUSKAAN DUTT
How to convert this pseudo code into JAVA
D = 1
coeff_array[0] = select random integer between -5 and 5
coeff_array[1] = select random integer between -5 and 5
coeff_array[2] = select random integer between -5 and 5
D = 2
coeff_array[0] = select random integer between -10 and 10
coeff_array[1] = select random integer between -10 and 10
coeff_array[2] = select random integer between -10 and 10
D = 3
remove an integer k from {0,1,2} at random
let remaining array be {p, q}
coeff_array[p] = select random integer between -15 and 15
coeff_array[q] = select random integer between -15 and 15
To find coeff_array[k]:
{
j = select a random integer from the set {2,3,5,6,7}
string sign = + or - (select one of the two at random)
string coeff_array[k] = "sign" + "r" + j;
}
D = 4
to select coeff_array[0]
select an integer i at random from 1 to 100
if i < 50
coeff_array[0] = select random integer between -20 and 20
else
j = select a random integer from the set {2,3,5,6,7,8,10,11,12,13,14,15}
string sign = + or - (select one of the two at random)
int multiplier = select a random integer from {2,3,4,5}
string coeff_array[0] = "sign" + "multiplier" + "r" + j;
Similarlly, select coeff_array[1] and coeff_array[2]
• March 2nd, 2013, 08:36 AM
Norm
Re: How to convert this pseudo code into JAVA