Aatul Palandurkar

Author Archive

  • In: Tutorials
  • Comments Off on Fatake Tikli fodne ka purana tarika #shorts

via https://youtu.be/TzkeeOCMAAE

  • In: Tutorials
  • Comments Off on Hidden WhatsApp Feature 2021 #short
  • In: Tutorials
  • Comments Off on How to post on Instagram from Desktop 2021 | Post on Instagram from Computer 2021 Step by Step Guide

Objectives:

  • Write a Java program to to generate random numbers and print the same
  • Write a program to generate random numbers
  • Write a program to generate random numbers in Java

Java Program:


import java.util.Scanner;
import java.util.Random;

class GenerateRandomNumber
{
public static void main(String[] args)
{
int maxRange;

//create objects
Scanner SC = new Scanner(System.in);
Random rand = new Random();

System.out.print("Please enter maximum range: ");
maxRange=SC.nextInt();

for(int i=1; i<=10; i++)
{
System.out.println(rand.nextInt(maxRange));
}
}
}

Output:

Please enter maximum range: 500
467
61
100
449
68
316
445
224
54
498


Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 13,214 other followers

Tweets

YouTube

Archives

%d bloggers like this: