This question already has an answer here:
i was wondering if i could generate numbers from 11-99, excluding the numbers 0-10? Is that even possible to make with a random generator? here's e piece of my code
import java.util.*;
public class clas1 { public int min;
public int[] tabele() {
Random r = new Random();
int d;
int e[]= new int[100];
for(int i=0; i<e.length;i++){
d=r.nextInt(99)+11;
e[i]=d;
System.out.println(e[i]);
}
return e;
}
public void emin(int[] e) {
Random r = new Random();
int d;
for(int i=0; i<e.length;i++){
d=r.nextInt(100);
e[i]=d;
if(e[i]<min){
min=e[i];
}
}
System.out.println("Vlera me e vogel eshte: " +min);
}
public static void main(String []args){
clas1 prova = new clas1();
int[] arr = prova.tabele();
prova.emin(arr);
}
}
Aucun commentaire:
Enregistrer un commentaire