Hello, everyone! I am trying to generate a random number with Java, but random with the fix number of reviewers per object.Example: I have 5 reviewers(r(i)) and 5 objects(o(j)), a[j] is the evaluation score that reviewer(r(i)) has evaluated object(o(j)), and my question is i want to labeled each object should have evaluated only 3 reviewers.

I have tried the following code, but I still have problems: the result was: each object are evaluated by all reviewers.


double[][] a= new double[5][5];
        int i,j;
        int [] m= new int[5];
        Random rand=new Random();
        
           for(i=0; i<5; i++ ){
              for(j=0; j<5; j++){   
           
                do{ 
                    a[i][j]= rand.nextDouble();
                    if(a[i][j]>0.0)
                     m[j]++;
                     System.out.println("a[" + i + "][" + j + "] = " +a[i][j]);
   
                }while( m[j]==3);
	                 
                            }
            }
  
            }
}

Could you suggest how to solve my problem, or point me to some references?

Thanks in advance!!!!

Please print out the contents of the array and explain what is wrong with its contents and show a sample of what it should look like.

The Arrays class's toString() method is useful for formatting a single dim array for printing.

Please print out the contents of the array and explain what is wrong with its contents and show a sample of what it should look like.

The Arrays class's toString() method is useful for formatting a single dim array for printing.

This is the out put of my code:
a[0][0] = 0.15512296822396665
a[0][1] = 0.5456415485550908
a[0][2] = 0.9995046626175654
a[0][3] = 0.03385491801693197
a[0][4] = 0.22820199148918685
a[1][0] = 0.02280706350675965
a[1][1] = 0.21260196696186395
a[1][2] = 0.6063509010826033
a[1][3] = 0.2290916607369855
a[1][4] = 0.10974681301631473
a[2][0] = 0.5856622809573245
a[2][0] = 0.018607218476241028
a[2][1] = 0.8358366198826916
a[2][1] = 0.5937235625094165
a[2][2] = 0.5870013311635774
a[2][2] = 0.04336009215977099
a[2][3] = 0.17751727664240868
a[2][3] = 0.9578408178738987
a[2][4] = 0.08293777088498355
a[2][4] = 0.28552299147671434
a[3][0] = 0.33679362149228653
a[3][1] = 0.0978680160768769
a[3][2] = 0.6143377242655492
a[3][3] = 0.6107299272520841
a[3][4] = 0.35513940581798953
a[4][0] = 0.7087557600240727
a[4][1] = 0.39736134803361434
a[4][2] = 0.5726245415739528
a[4][3] = 0.8959484600724743
a[4][4] = 0.9005641544273156

but my propose is :
but for range not fix it can be any valeu, in my code just give you an example
a[1][0]= 0.9005641544273156
a[2][0]= 0.35513940581798953
a[4][0]= 0.08293777088498355

a[0][1]= 0.35513940581798953
a[1][1]= 0.08293777088498355
a[3][1]= 0.35513940581798953

a[1][2]= 0.018607218476241028
a[3][2]= 0.5726245415739528
a[4][2]= 0.8959484600724743

a[0][3]= 0.10974681301631473
a[2][3]= 0.6063509010826033
a[3][3]= 0.9995046626175654

a[2][4]= 0.21260196696186395
a[3][4]= 0.8358366198826916
a[4][4]= 0.17751727664240868

but for range not fix it can be any valeu, in my code just give you an example

Sorry I have no idea what you are saying or what the print outs you posted show.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.