answersLogoWhite

0


Best Answer

Here is the final code for a program that RETURNS the number (from another method to the main method):

import java.util.*;

public class Example

{

public static void main(String[] args)

{

Scanner in = new Scanner(System.in);

System.out.println("Please enter two numbers to generate a number between (inclusive) those two numbers");

System.out.println("Please enter the first:");

int d = in.nextInt();

System.out.println("Please enter the second:");

int e = in.nextInt();

int g = randomBetween(d, e);

}

public static int randomBetween(int d, int e)

{

Random random = new Random();

int f = random.nextInt(e-d+1)+d;

return f;

}

}

We are not allowed to put links in the answer to a question, so I have now put the link to a video explaining this code in the related links area.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you make a java program return a random number between two numbers inputed by the user?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering
Related questions

How do you solve this program wap to print sum of a digit of an inputed number?

wap to print all the arnstrong no. between 100&1000


Prime numbers between 1 to 10 in microprocessor 8085?

program to find prime number in 8085 microprocessor


Program to count the number of numbers in an array using 8085 microprocessor?

A program which is used to count the number of numbers in an array using a 8085 microprocessor is known as a assembly language program.


What number is between the fractions 10.40 and 20.50?

These are decimals and there are an infinite number of numbers between these numbers.


Program for print prime all number from 1 to 100 in foxpro?

Prime numbers are numbers that are only divisible by themselves and the number 1. You can write a program to print all prime numbers from 1 to 100 in FoxPro.


What number is between 3 5 and 7 10?

There are no prime numbers in between these numbers. The only whole number between them is 6


What is next decimal number of the number 65?

There is no such thing as a "next" decimal number. Numbers are infinitely dense: that is, between any two numbers there are infinitely many numbers. Therefore, given any number claiming to be next after 65, there are infinitely many numbers between 65 and that number - The smallest of these has a better claim at being next. But there are infinitely many numbers between 65 and this number.There is no such thing as a "next" decimal number. Numbers are infinitely dense: that is, between any two numbers there are infinitely many numbers. Therefore, given any number claiming to be next after 65, there are infinitely many numbers between 65 and that number - The smallest of these has a better claim at being next. But there are infinitely many numbers between 65 and this number.There is no such thing as a "next" decimal number. Numbers are infinitely dense: that is, between any two numbers there are infinitely many numbers. Therefore, given any number claiming to be next after 65, there are infinitely many numbers between 65 and that number - The smallest of these has a better claim at being next. But there are infinitely many numbers between 65 and this number.There is no such thing as a "next" decimal number. Numbers are infinitely dense: that is, between any two numbers there are infinitely many numbers. Therefore, given any number claiming to be next after 65, there are infinitely many numbers between 65 and that number - The smallest of these has a better claim at being next. But there are infinitely many numbers between 65 and this number.


find the prime number between two number?

There need not be any prime number between them.


What are two numbers that are in between the number 0.6 on the number line?

It is impossible to be in between one number.


What is the rational number between square root of 29 and 45?

There are an infinite number of rational numbers between these two numbers, but the only positive integer between these numbers is 6.


What between 4 and 5 in number lines?

There are infinitely many numbers between any two different numbers. To find a number exactly in the middle between two numbers, calculate the average. That is, add the two numbers, then divide the result by 2.


What is the median number of 11.5 and 22.5?

It is the number halfway between them or half of the total of the two numbers, so 17 is the median.It is the number halfway between them or half of the total of the two numbers, so 17 is the median.It is the number halfway between them or half of the total of the two numbers, so 17 is the median.It is the number halfway between them or half of the total of the two numbers, so 17 is the median.It is the number halfway between them or half of the total of the two numbers, so 17 is the median.It is the number halfway between them or half of the total of the two numbers, so 17 is the median.It is the number halfway between them or half of the total of the two numbers, so 17 is the median.It is the number halfway between them or half of the total of the two numbers, so 17 is the median.It is the number halfway between them or half of the total of the two numbers, so 17 is the median.It is the number halfway between them or half of the total of the two numbers, so 17 is the median.It is the number halfway between them or half of the total of the two numbers, so 17 is the median.