Answer:
Here are the two statements which use nextInt() to print two random integers between 0 and 9:
System.out.println(randGen.nextInt(10));
System.out.println(randGen.nextInt(10));
Explanation:
Here is the complete program:
import java.util.Scanner; //to accept input from user
import java.util.Random; // use to generate random numbers
public class DiceRoll { //class definition
public static void main (String [] args) {//start of main function
Random randGen = new Random(); // creates a Random class object randGen
int seedVal = 0; //sets starting point for generating random numbers
randGen.setSeed(seedVal); //sets the seed of random number generator
System.out.println(randGen.nextInt(10)); //generates and prints the first random integer between 0 and 9 (10 is the range from 0 to 9) using nextInt method, which is used to get next random integer value from the sequence of random number generator
System.out.println(randGen.nextInt(10)); //generates and prints the second random integer between 0 and 9 (10 is the range from 0 to 9) using nextInt method
return; } }
Another way to write this is to initialize two int variables:
int integer1;
int integer2;
Now use two print statements to print these random integers between 0 and 9 as:
System.out.println(integer1= randGen.nextInt(10));
System.out.println(integer1= randGen.nextInt(10));
Another way to write this is:
Set the value of integer1 to a random number from 0 to 9 and same for integer2
int integer1 = randGen.nextInt(10);
int integer2 = randGen.nextInt(10);
Now use two print statements to print these random integers between 0 and 9 as:
System.out.println(integer1);
System.out.println(integer2);