At Westonci.ca, we provide reliable answers to your questions from a community of experts. Start exploring today! Join our Q&A platform and connect with professionals ready to provide precise answers to your questions in various areas. Our platform provides a seamless experience for finding reliable answers from a network of experienced professionals.

Create the arrays and assign randomized values for each element in the array. The randomized values should range from 1 to twice the size of the array. For example, for an array of 200, assign random values between 1 and 400. Use a constant for the size of the array. Edit the value of the constant in different runs of the program to account for the various array sizes.

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]+" ");      }

Thank you for your visit. We're dedicated to helping you find the information you need, whenever you need it. Thank you for visiting. Our goal is to provide the most accurate answers for all your informational needs. Come back soon. We're here to help at Westonci.ca. Keep visiting for the best answers to your questions.