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 Pollard Rho Algorithm
Java Program to Implement VList
Java Program to Find Nearest Neighbor for Static Data Set
Spring Boot - Securing Web Applications
Java Program to Implement Max Heap
Spring Cloud Bus
A Guide to ConcurrentMap
Spring Security with Maven
JUnit 5 for Kotlin Developers
Spring Boot Configuration with Jasypt
Sử dụng JDBC API thực thi câu lệnh truy vấn dữ liệu
The Thread.join() Method in Java
Java – Convert File to InputStream
Java Program to Implement ScapeGoat Tree
Java Program to Implement Best-First Search
Spring Boot - Batch Service
Vòng lặp for, while, do-while trong Java
Comparing Two HashMaps in Java
Java Program to Find Whether a Path Exists Between 2 Given Nodes
Immutable ArrayList in Java
A Guide to Java SynchronousQueue
Sorting in Java
Java Program to Implement Gauss Jordan Elimination
An Intro to Spring Cloud Zookeeper
Java Program to Implement CountMinSketch
Java Map With Case-Insensitive Keys
Java Program to Implement Skew Heap
Hướng dẫn Java Design Pattern – Visitor
Spring Security Custom AuthenticationFailureHandler
An Intro to Spring Cloud Security
Java Program to Check the Connectivity of Graph Using DFS
Java Program to Implement LinkedHashSet API