mardi 15 octobre 2019

How to print and load an array with random numbers

I need to display a list of 10 random double numbers in order and spaced out in a row. This is what I have so far:

double [] array;
    array = new double [10];
    for (int i = 0 ; i <array.length; i++) {
     array[i] =  Math.random()*((100 - 0)-1);
        printArray(array);
    }


}
public static void printArray(double [] array) {
    for (double eachElement: array){
        System.out.printf("%f." , eachElement);

        }



Aucun commentaire:

Enregistrer un commentaire