├── NumberGenerator.java └── README.md /NumberGenerator.java: -------------------------------------------------------------------------------- 1 | import java.util.Random; 2 | 3 | public class RandomNumberGenerator { 4 | public static void main(String[] args) { 5 | int min = 1; // Minimum value of the random number 6 | int max = 100; // Maximum value of the random number 7 | System.out.println(generateRandomNumber(min, max)); 8 | } 9 | 10 | public static int generateRandomNumber(int min, int max) { 11 | Random random = new Random(); 12 | return random.nextInt(max - min + 1) + min; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Random Number Generator 🎲 2 | 3 | This simple Java program generates random numbers within a specified range. 4 | 5 | ## Introduction ℹ️ 6 | 7 | This program uses Java's built-in `Random` class to generate random numbers between a minimum and maximum value. 8 | 9 | ## Features ✨ 10 | 11 | - **Customizable Range**: Specify the minimum and maximum values for the generated random number. 12 | - **Uniform Distribution**: Generates random numbers with uniform distribution within the specified range. 13 | - **Easy to Use**: Simple command-line interface for generating random numbers. 14 | 15 | ## Usage 🖥️ 16 | 17 | 1. Clone or download the repository. 18 | 2. Compile the `NumberGenerator.java` file. 19 | 3. Run the compiled Java program. 20 | 4. Follow the instructions to enter the minimum and maximum values for the random number range. 21 | 5. The program will generate and display a random number within the specified range. 22 | 23 | ## Example 24 | 25 | ```bash 26 | $ javac RandomNumberGenerator.java 27 | $ java RandomNumberGenerator 28 | Enter the minimum value: 1 29 | Enter the maximum value: 100 30 | Generated random number: 42 31 | --------------------------------------------------------------------------------