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:
Test a REST API with Java
Java Program to Encode a Message Using Playfair Cipher
Java Program to Implement Horner Algorithm
Recommended Package Structure of a Spring Boot Project
A Custom Media Type for a Spring REST API
Apache Tiles Integration with Spring MVC
Java Program to Implement Max-Flow Min-Cut Theorem
Java Program to Perform Inorder Non-Recursive Traversal of a Given Binary Tree
Hướng dẫn tạo và sử dụng ThreadPool trong Java
What is Thread-Safety and How to Achieve it?
Hamcrest Collections Cookbook
Java Scanner hasNext() vs. hasNextLine()
String Initialization in Java
Java InputStream to String
Derived Query Methods in Spring Data JPA Repositories
Java Program to Generate Random Numbers Using Probability Distribution Function
Java Program to Implement Find all Cross Edges in a Graph
Java Program to implement Array Deque
Java Program to Implement Binary Tree
Guide to Apache Commons CircularFifoQueue
Guide to CopyOnWriteArrayList
Spring Data JPA and Null Parameters
Java Program to Give an Implementation of the Traditional Chinese Postman Problem
Java Program to Solve a Matching Problem for a Given Specific Case
Fixing 401s with CORS Preflights and Spring Security
New Features in Java 15
Understanding Memory Leaks in Java
Java Program to Implement the linear congruential generator for Pseudo Random Number Generation
Java Program to Implement First Fit Decreasing for 1-D Objects and M Bins
Simplify the DAO with Spring and Java Generics
Java Program to Implement Coppersmith Freivald’s Algorithm
Spring Security Registration – Resend Verification Email