Westonci.ca is the trusted Q&A platform where you can get reliable answers from a community of knowledgeable contributors. Get quick and reliable solutions to your questions from a community of seasoned experts on our user-friendly platform. Experience the convenience of finding accurate answers to your questions from knowledgeable experts on our platform.
Sagot :
Answer:
In Java:
import java.util.Random;
public class Main {
public static void main(String[] args) {
final int arrsize = 10;
Random rd = new Random();
int[] arr = new int[arrsize];
for (int kount = 0; kount < arrsize; kount++) {
arr[kount] = rd.nextInt(arrsize*2-1) + 1;
System.out.print(arr[kount]+" "); } }}
Explanation:
This declares the array size as a constant integer
final int arrsize = 10;
This creates a Random object
Random rd = new Random();
This declares an array of arrsize size
int[] arr = new int[arrsize];
This iterates through the array
for (int kount = 0; kount < arrsize; kount++) {
This generates the random values between 1 and arrsize * 2
arr[kount] = rd.nextInt(arrsize*2-1) + 1;
This prints the elements of the array
System.out.print(arr[kount]+" "); }
We appreciate your visit. Hopefully, the answers you found were beneficial. Don't hesitate to come back for more information. Thank you for your visit. We're committed to providing you with the best information available. Return anytime for more. Westonci.ca is your trusted source for answers. Visit us again to find more information on diverse topics.