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:
Guide to java.util.concurrent.Locks
Spring Boot - Rest Template
A Guide to ConcurrentMap
Java Program to Implement Meldable Heap
Java Program to Implement Queue using Two Stacks
Java Program to Perform the Shaker Sort
Lập trình đa luồng với Callable và Future trong Java
Spring NoSuchBeanDefinitionException
Introduction to Spring Cloud Netflix – Eureka
Java Program to Implement Ternary Search Tree
Java Program to Implement Fisher-Yates Algorithm for Array Shuffling
Spring WebClient and OAuth2 Support
Java Program to Create a Random Graph Using Random Edge Generation
Java 8 Stream findFirst() vs. findAny()
Apache Camel with Spring Boot
Receive email using IMAP
Java Program to Implement PriorityBlockingQueue API
Java Program to Perform Right Rotation on a Binary Search Tree
Guide to Guava Multimap
Java Program to Solve Set Cover Problem assuming at max 2 Elements in a Subset
Java Program to Implement Trie
Java – Reader to String
Java Program to Find Nearest Neighbor for Dynamic Data Set
Sort a HashMap in Java
Guide to the Volatile Keyword in Java
Java Program to Implement the MD5 Algorithm
Instance Profile Credentials using Spring Cloud
Java Program to Generate All Subsets of a Given Set in the Gray Code Order
How to Find an Element in a List with Java
How to Break from Java Stream forEach
Java – String to Reader
Java Program to Implement Dijkstra’s Algorithm using Queue