Welcome to Westonci.ca, the place where your questions find answers from a community of knowledgeable experts. Get quick and reliable solutions to your questions from a community of experienced experts on our platform. Discover in-depth answers to your questions from a wide network of professionals on our user-friendly Q&A 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]+" "); }
Thanks for using our platform. We're always here to provide accurate and up-to-date answers to all your queries. We hope you found what you were looking for. Feel free to revisit us for more answers and updated information. Westonci.ca is here to provide the answers you seek. Return often for more expert solutions.