JAVA: Write the Psuedocode for a generic algorithm that uses the .nextINT method on an object to generate a random number in the range min to max where min and max are integers.
Psuedocode:
start:
int max=10;
int min=5;
Random random = new Random();
int randomNum = random.nextInt((max - min + 1) + min;
print randomNum;
end;
Java Code:
import java.util.Random;
public class RandomNumTest {
public static void main(String[] args) {
//creating Random class
object
Random random = new Random();
int randomNum = random.nextInt((max
- min) + 1) + min;
System.out.println("Random
number:"+randomNum);
}
}
Output:
Random number:7
Get Answers For Free
Most questions answered within 1 hours.