mardi 23 juillet 2019

function to generate and display N random numbers between 0 and 1

I have to generate randoms numbers, i have a code running and working, but it doesnt seems random, it generates sequences, is right anyway? or is there another way to do this

public static void main(String[] args) {

    Scanner teclado = new Scanner(System.in);
    System.out.println("Ingrese el numero N");
    int n = teclado.nextInt();

    for (int i = 1; i <= n; i++){

        double d = numerosAleatorios(i,n);
        System.out.println(d);
    }

}

public static double numerosAleatorios(double b, double c){

     return  b / c;
}




Aucun commentaire:

Enregistrer un commentaire