Welcome to Westonci.ca, the place where your questions find answers from a community of knowledgeable experts. Get precise and detailed answers to your questions from a knowledgeable community of experts on our Q&A platform. Explore comprehensive solutions to your questions from a wide range of professionals on our user-friendly platform.
Sagot :
Answer:
The method is as follows:
public static void randomStar(Random r, int num) {
int n;
do {
n = 5 + r.nextInt(15);
for(int count = 0; count < n; count++){
System.out.print("*");
}
System.out.println();
} while(n < num);
}
Explanation:
This defines the method
public static void randomStar(Random r, int num) {
This declares n as integer
int n;
The following is repeated until n >= num
do {
This generates a random number for n (5 and 19)
n = 5 + r.nextInt(15);
The following loop prints n *'s
for(int count = 0; count < n; count++){
System.out.print("*");
}
This prints n
System.out.println();
} while(n < num); The loop is repeated as long as the condition is valid
}
Thank you for choosing our platform. We're dedicated to providing the best answers for all your questions. Visit us again. We appreciate your time. Please revisit us for more reliable answers to any questions you may have. Thank you for trusting Westonci.ca. Don't forget to revisit us for more accurate and insightful answers.