dimanche 11 octobre 2020

How can I write an array generator that generates numbers in certain column values?

Hi there :) I wrote this array generator and would like to rewrite it so that you can set the value ranges from which the individual column values come.

So as an example: the first columns are either 0 or 1, the values to the right of them are either 3 or 7 and the values of the other columns are between 0 and 1 (so as it is at the moment for all numbers).

1 ; 3 ; 0.68618 ; 0.98135 ; 0.25489 ; ...

1 ; 7 ; 0.32481 ; 0.25871 ; 0.14697 ; ...

0 ; 7 ; 0.96125 ; 0.36815 ; 0.24863 ; ...

......

public class scratch{

    public static void main(String[] args) {
        double values[][] = new double[10][19];
        for (int i = 0; i < values.length; i++) {

            for (int j = 0; j < values[i].length; j++) {

                values[i][j] = ((double) (Math.random()));
                System.out.print(values[i][j]+" ; ");
            }
            System.out.println();

        }
    }
}

PS: please excuse my bad english




Aucun commentaire:

Enregistrer un commentaire