This is java program to generate the random numbers, in the range given by the user. Range could be any numbers of size integer supported by Java.
Here is the source code of the Java Program to Generate Randomized Sequence of Given Range of Numbers. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
//This is the sample program to generate a randomized sequence of numbers
import java.util.Random;
import java.util.Scanner;
public class Randomized_Sequence_Random_Numbers
{
public static void main(String args[])
{
Random rand = new Random();
Scanner sc = new Scanner(System.in);
System.out.println("Enter the starting and ending of the sequence: ");
int start = sc.nextInt();
int end = sc.nextInt();
for(int i=0; i<15; i++)
{
System.out.print(rand.nextInt(end-start+1)+start + ", ");
}
System.out.print("...");
sc.close();
}
}
Output:
$ javac Randomizied_Sequence_Random_Numbers.java $ java Randomizied_Sequence_Random_Numbers Enter the starting and ending of the sequence: 100 1000 490, 574, 179, 447, 723, 891, 589, 312, 667, 653, 375, 667, 990, 573, 399, ...
Related posts:
Java Program to Implement the RSA Algorithm
Java Program to Construct a Random Graph by the Method of Random Edge Selection
LinkedHashSet trong java
Spring Boot - Hystrix
Send an email with an attachment
Java Program to Implement Treap
Comparing Arrays in Java
Immutable Map Implementations in Java
Hướng dẫn sử dụng lớp Console trong java
Getting the Size of an Iterable in Java
Java Multi-line String
Java Program to implement Bit Set
Java Program to Find kth Smallest Element by the Method of Partitioning the Array
Spring @RequestParam Annotation
Java Program to Implement Miller Rabin Primality Test Algorithm
Java Program to Implement the Bin Packing Algorithm
Versioning a REST API
Optional trong Java 8
Giới thiệu Json Web Token (JWT)
Generating Random Numbers in a Range in Java
Java – Try with Resources
A Custom Media Type for a Spring REST API
Limiting Query Results with JPA and Spring Data JPA
Java Program to Perform Polygon Containment Test
Java Program to Implement CopyOnWriteArrayList API
Java Program to Implement Graph Coloring Algorithm
Java Program to Implement Hash Trie
JUnit 5 @Test Annotation
Get the workstation name or IP
Java Program to Implement WeakHashMap API
Using Spring @ResponseStatus to Set HTTP Status Code
Java Program to Generate a Random UnDirected Graph for a Given Number of Edges