Write a Java method random to return a positive integer from 1 to n. Note that Math.random(), returns a double x, such that 0.0 <= x < 1.0. The below code also uses, asserts. An assert is like the if expression, except that if condition fails, the program throws an exception. Here, it helps you check if the result is actually less than or equal to n. You can turn on asserts as follow: Go to Run -> Run Configurations. Go to Arguments tab and in VM arguments give \"-ea\" (without quotes). import java.util.Scanner; public class RandomNumbers { public static int random(int n){ //your code } public static void main(String[] args) { Scanner input = new Scanner(System.in); int num = input.nextInt(); int result = random(num); assert result <= num; System.out.println(result); } } Solution RandomNumbers.java import java.util.Scanner; public class RandomNumbers { public static int random(int n){ //your code return (int)(Math.random() * n) + 1; } public static void main(String[] args) { Scanner input = new Scanner(System.in); int num = input.nextInt(); int result = random(num); assert result <= num; System.out.println(result); } } Output: 56 25 .