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:
Send an email with an attachment
Java Program to Optimize Wire Length in Electrical Circuit
Mảng (Array) trong Java
Quick Guide to Spring Bean Scopes
Generating Random Numbers in a Range in Java
Java Program to Implement the Hungarian Algorithm for Bipartite Matching
Connect through a Proxy
Object cloning trong java
List Interface trong Java
Fixing 401s with CORS Preflights and Spring Security
Giới thiệu Aspect Oriented Programming (AOP)
Java Program to Implement TreeSet API
Java Program to Check Whether an Undirected Graph Contains a Eulerian Path
Java Program to Describe the Representation of Graph using Incidence List
Java Program to Represent Graph Using 2D Arrays
Check if there is mail waiting
Java Program to Generate Random Numbers Using Probability Distribution Function
Overview of Spring Boot Dev Tools
Java Program to Perform Left Rotation on a Binary Search Tree
A Comparison Between Spring and Spring Boot
Hướng dẫn Java Design Pattern – Flyweight
Map Interface trong java
Java Program to Implement Sorted Vector
Quick Guide to java.lang.System
Java Program to Generate Random Partition out of a Given Set of Numbers or Characters
Java Program to Find the Minimum value of Binary Search Tree
New Features in Java 9
What is Thread-Safety and How to Achieve it?
A Quick Guide to Spring MVC Matrix Variables
Java Program to find the maximum subarray sum using Binary Search approach
Spring Boot - Google OAuth2 Sign-In
“Stream has already been operated upon or closed” Exception in Java