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 Interval Tree
Java Program to Implement ConcurrentLinkedQueue API
Java Program to Convert a Decimal Number to Binary Number using Stacks
Java Program to Implement Adjacency Matrix
Java Program to Implement Counting Sort
Java Program to Implement Pairing Heap
Sử dụng CountDownLatch trong Java
Tránh lỗi ConcurrentModificationException trong Java như thế nào?
Converting Between an Array and a Set in Java
Java Program to Compare Binary and Sequential Search
Service Registration with Eureka
Java Program to Test Using DFS Whether a Directed Graph is Weakly Connected or Not
Java Program to Compute DFT Coefficients Directly
Handling URL Encoded Form Data in Spring REST
Hướng dẫn Java Design Pattern – Mediator
Allow user:password in URL
Guide to ThreadLocalRandom in Java
Period and Duration in Java
Spring Cloud – Securing Services
Guide to CopyOnWriteArrayList
The DAO with JPA and Spring
Lập trình đa luồng với CompletableFuture trong Java 8
How to Iterate Over a Stream With Indices
A Guide to the finalize Method in Java
Life Cycle of a Thread in Java
OAuth 2.0 Resource Server With Spring Security 5
Using a Mutex Object in Java
Guide to Mustache with Spring Boot
Marker Interface trong Java
Java Program to Find Number of Spanning Trees in a Complete Bipartite Graph
Command-Line Arguments in Java
Java Program to Implement Jarvis Algorithm