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 Bin Packing Algorithm
Java Program to Implement Extended Euclid Algorithm
Spring REST API + OAuth2 + Angular
Các kiểu dữ liệu trong java
Giới thiệu SOAP UI và thực hiện test Web Service
Basic Authentication with the RestTemplate
Java Program to Permute All Letters of an Input String
SOAP Web service: Upload và Download file sử dụng MTOM trong JAX-WS
Java Program to implement Bit Matrix
Sort a HashMap in Java
Java Program to Implement Attribute API
Spring Boot - File Handling
Extract links from an HTML page
Hướng dẫn Java Design Pattern – Chain of Responsibility
Java Program to Implement Graham Scan Algorithm to Find the Convex Hull
ThreadPoolTaskExecutor corePoolSize vs. maxPoolSize
Java Program to Solve a Matching Problem for a Given Specific Case
Java Program to Implement Ternary Search Tree
Hướng dẫn sử dụng Java Annotation
Java Program to Sort an Array of 10 Elements Using Heap Sort Algorithm
Java Program to Represent Graph Using Incidence List
Java Program to Implement Min Heap
Java Program to do a Breadth First Search/Traversal on a graph non-recursively
Quick Guide to java.lang.System
Java Program to Generate Random Hexadecimal Byte
Java Program to Describe the Representation of Graph using Incidence List
Java Program to Find k Numbers Closest to Median of S, Where S is a Set of n Numbers
Spring Boot - Cloud Configuration Client
Java Program to Implement a Binary Search Tree using Linked Lists
Jackson JSON Views
Guide to PriorityBlockingQueue in Java
SOAP Web service: Authentication trong JAX-WS