I'm building a program to generate random 9 digit number for students to enroll in a college/university. I have been using the random object to generate random studentID numbers for students. It works, however, I noticed that it also generates negative number. I'm wondering how to get rid of the negative number and only include positive numbers.
Random rand = new Random();
int studentID = rand.nextInt();
System.out.println("Your student ID number is: " + studentID);
Aucun commentaire:
Enregistrer un commentaire