samedi 3 octobre 2020

How do I make a random int? [duplicate]

So I am trying to make 100 random integers from 1-100 print out. I can make doubles of this but not integers. Please show me how to make this into integers, here is the code.

for(i = 1; i <= 100; i++) {
    double r = Math.random();
    double in = r * 100;
    System.out.print(in + ", ");
}  

Please show me what I messed up or if I need to use an alternate technique for this




Aucun commentaire:

Enregistrer un commentaire