In this program you can enter a lower and upper limit, and between these values the program creates a random value (ideal for situations where you can't decide).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import java.io.*; import java.util.Scanner; class Testprogram { public static void main(String [] args) { long eingabe1, eingabe2, zufallszahl; Scanner eingabe = new Scanner(System.in); System.out.println("Please enter a lower limit!"); eingabe1 = Integer.valueOf(eingabe.next()); System.out.println("Plase enter an upper limit!"); eingabe2 = Integer.valueOf(eingabe.next()); zufallszahl = ((int) (Math.random()*eingabe2)) + eingabe1; System.out.println(""); System.out.println("The random value is: " + zufallszahl); }