ICSE Class 9 Computer Applications
Question 7 of 16
Mathematical Library Methods — Question 7
Back to all questions 7
Question Question 7
Write a program to generate random integers in the range 10 to 20.
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
