Answer:
The method in Java is as follows:
public static void randomValues(){
Random r = new Random();
int sentinel = 10;
int randNum = r.nextInt(24) + 1;
while(randNum!=sentinel){
System.out.print(randNum+" ");
randNum = r.nextInt(24) + 1;
}
System.out.print(sentinel);
}
Explanation:
This defines the method
public static void randomValues(){
This creates a random object, r
Random r = new Random();
This sets the sentinel value to 0
int sentinel = 10;
This generates a random number
int randNum = r.nextInt(24) + 1;
This loop is repeated until the the random number is 10
while(randNum!=sentinel){
Print the generated number
System.out.print(randNum+" ");
Generated another random number
randNum = r.nextInt(24) + 1; }
Print the sentinel (i.e. 10)
System.out.print(sentinel);
}