generate random number in java
import java.lang.Math;
int randomNumber;
int minimum = 1;
int maximum = 10 - minimum;
randomNumber = (int)((Math.random()*maximum) + minimum);
System.out.println("Random Number (Between 1-10): " + randomNumber);
generate random number in java
import java.lang.Math;
int randomNumber;
int minimum = 1;
int maximum = 10 - minimum;
randomNumber = (int)((Math.random()*maximum) + minimum);
System.out.println("Random Number (Between 1-10): " + randomNumber);
Generate Random number using Math.random in Java
class GenerateRandom {
public static void main( String args[] ) {
int min = 50;
int max = 100;
//Generate random int value from 50 to 100
System.out.println("Random value in int from "+min+" to "+max+ ":");
int random_int = (int)Math.floor(Math.random()*(max-min+1)+min);
System.out.println(random_int);
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us