Computer Applications

Write a program to generate random integers in the range 10 to 20.

Java

Java Math Lib Methods

36 Likes

Answer

public class KboatRandom
{
    public static void main(String args[]) {
        int min = 10, max = 20;
        int range = max - min + 1;
        int num = (int)(range * Math.random() + min);
        System.out.println("Random number in the range 10 to 20: " + num);
    }
}

Output

Answered By

15 Likes


Related Questions