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 Quick Hull Algorithm to Find Convex Hull
Java Program to Implement LinkedTransferQueue API
Spring Security and OpenID Connect
Lập trình đa luồng trong Java (Java Multi-threading)
JUnit 5 for Kotlin Developers
Java Program to Use Boruvka’s Algorithm to Find the Minimum Spanning Tree
Java Program to Check whether Graph is a Bipartite using 2 Color Algorithm
Java Program to Implement Skew Heap
Java Switch Statement
Quick Guide to Spring MVC with Velocity
Guava Collections Cookbook
Quick Guide to Spring Controllers
JUnit5 @RunWith
Custom JUnit 4 Test Runners
Java – Convert File to InputStream
Java Program to Implement Brent Cycle Algorithm
Java Program to find the maximum subarray sum O(n^2) time(naive method)
A Quick JUnit vs TestNG Comparison
Giới thiệu Swagger – Công cụ document cho RESTfull APIs
Java Program to Perform Partial Key Search in a K-D Tree
Recommended Package Structure of a Spring Boot Project
File Upload with Spring MVC
Simple Single Sign-On with Spring Security OAuth2
Configuring a DataSource Programmatically in Spring Boot
Guide to Selenium with JUnit / TestNG
Consumer trong Java 8
Intro to the Jackson ObjectMapper
Spring Security Authentication Provider
Java Program to Implement Self Balancing Binary Search Tree
Introduction to PCollections
The Order of Tests in JUnit
Setting Up Swagger 2 with a Spring REST API