-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandom.java
More file actions
25 lines (23 loc) · 809 Bytes
/
Copy pathrandom.java
File metadata and controls
25 lines (23 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import java.util.Random;
public class random {
public static void main(String[] args){
Random rd = new Random();
int n;
double num;
boolean isgood;
n=rd.nextInt(); // Range from -2B to 2B
System.out.println("Random integer : "+n);
n=rd.nextInt(1,101); // Range from 1 to 100 (100 is inclusive)
System.out.println("Random integer : "+n);
num = rd.nextDouble();
System.out.println("Random double : "+num);
num = rd.nextDouble(1,101);
System.out.println("Random double : "+num);
isgood= rd.nextBoolean();
System.out.println("Random boolean : "+isgood);
float number = rd.nextFloat();
System.out.println("Random float : "+number); // range from 0.0 to 1.0
number = rd.nextFloat(10);
System.out.println("Random float : "+number);
}
}