- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomClass.java
More file actions
Latest commit
20 lines (17 loc) · 512 Bytes
/
Copy pathRandomClass.java
File metadata and controls
20 lines (17 loc) · 512 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
importjava.security.SecureRandom;
importjava.util.Scanner;
publicclassRandomClass{
publicstaticvoidmain (String[] args) {
SecureRandomsecureRandom = newSecureRandom();
Scannerinput = newScanner(System.in);
System.out.print("Enter your number: ");
intuserInput = input.nextInt();
if (userInput <=0) {
System.out.println("Enter a positive number above 0");
}
else {
intnumber= secureRandom.nextInt(userInput);
System.out.printf("Random number is %d%n",number);
}
}
}