Answer:
Explanation:
The following code is written in Java. The function takes in the random object and creates a random number where it generates a random number and prints out the * characters, if the random number and the input num are the same it prints out both values and ends the function.
import java.util.Random;
class Brainly {
public static void main(String[] args) {
Random r = new Random();
randomStar(r, 12);
System.out.println();
randomStar(r, 19);
}
public static void randomStar(Random r, int num) {
while (true) {
int randomNum = r.nextInt(19) + 5;
if (randomNum != num) {
for (int x = 0; x < randomNum; x++) {
System.out.print("*");
}
System.out.print("\n");
} else {
for (int x = 0; x < randomNum; x++) {
System.out.print("*");
}
System.out.print("\n");
System.out.println("Random Number: " + randomNum);
System.out.println("Input Number: " + num);
break;
}
}
}
}